Implement TargetingPolicy, Cover can only target other allies
This commit is contained in:
parent
611601934d
commit
3e0004d4cb
21 changed files with 151 additions and 26 deletions
10
Assets/Battle/Targeting/AnyTargetPolicy.cs
Normal file
10
Assets/Battle/Targeting/AnyTargetPolicy.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AnyTargetPolicy: TargetingPolicy
|
||||
{
|
||||
public override bool CanTarget(BattleParticipant participant) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/Targeting/AnyTargetPolicy.cs.meta
Normal file
11
Assets/Battle/Targeting/AnyTargetPolicy.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 905e809c95dad9945b91b2a2f8906f54
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Battle/Targeting/OtheHeroTargetPolicy.cs
Normal file
16
Assets/Battle/Targeting/OtheHeroTargetPolicy.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OtherHeroTargetPolicy: TargetingPolicy
|
||||
{
|
||||
private BattleParticipant owner;
|
||||
|
||||
public OtherHeroTargetPolicy(BattleParticipant owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public override bool CanTarget(BattleParticipant participant) {
|
||||
return participant.IsHero() && participant != this.owner;
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/Targeting/OtheHeroTargetPolicy.cs.meta
Normal file
11
Assets/Battle/Targeting/OtheHeroTargetPolicy.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 929cb636783b68a4db231a06391a652e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Assets/Battle/Targeting/SingleTargeting.cs
Normal file
32
Assets/Battle/Targeting/SingleTargeting.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SingleTargeting
|
||||
{
|
||||
private TargetingPolicy targetingPolicy;
|
||||
private BattleParticipant participantClicked;
|
||||
|
||||
public SingleTargeting(TargetingPolicy targetingPolicy) {
|
||||
this.targetingPolicy = targetingPolicy;
|
||||
}
|
||||
|
||||
public bool CanTarget(BattleParticipant participant) {
|
||||
return this.targetingPolicy.CanTarget(participant);
|
||||
}
|
||||
|
||||
public IEnumerator ChooseTarget() {
|
||||
while (this.participantClicked == null) {
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void NotifyParticipantSpriteClicked(BattleParticipant paticipant) {
|
||||
this.participantClicked = paticipant;
|
||||
}
|
||||
|
||||
public BattleParticipant GetTarget() {
|
||||
return this.participantClicked;
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/Targeting/SingleTargeting.cs.meta
Normal file
11
Assets/Battle/Targeting/SingleTargeting.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2e3ab2e9de8e9054ca09847226a7c1a6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Battle/Targeting/TargetingPolicy.cs
Normal file
8
Assets/Battle/Targeting/TargetingPolicy.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class TargetingPolicy
|
||||
{
|
||||
public abstract bool CanTarget(BattleParticipant participant);
|
||||
}
|
||||
11
Assets/Battle/Targeting/TargetingPolicy.cs.meta
Normal file
11
Assets/Battle/Targeting/TargetingPolicy.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 532a5ac0339ee5a4fb5c9e7888f0dd5f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Add table
Add a link
Reference in a new issue