示例#1
0
 private void ProcessAttackDone(ActionManager.AttackResult queryResult = ActionManager.AttackResult.InvalidTarget)
 {
     CallerResultCallback(_queryResult);
     Destroy(gameObject);
 }
示例#2
0
    private void ProcessAttack(Collider2D other)
    {
        ActorStats othersStats = null;

        othersStats = other.GetComponent <ActorStats>();

        //If the other doesn't have gamestats it's not something we can interact with
        if (othersStats == null)
        {
            return;
        }

        if (other.GetComponent <InfectActor>() || other.GetComponent <KillActor>())
        {
            return;
        }

        //Don't attack the same type
        if (CallerStats.Infected == othersStats.Infected)
        {
            return;
        }

        //Can't (or don't want to) kill a cell in the process of being infected.
        if (othersStats.BeingInfectedBy != null && !othersStats.Infected)
        {
            //But only if we're not the one infecting them
            if (othersStats.BeingInfectedBy != CallingGameObject)
            {
                return;
            }
        }

        _queryResult = ResolveAttack(CallerStats, othersStats);

        switch (_queryResult)
        {
        case ActionManager.AttackResult.InvalidTarget:
            break;

        case ActionManager.AttackResult.VictimDeath:
        {
            if (StatusChangeUIPrefab)
            {
                if (othersStats.Infected)
                {
                    SpawnStatusChange("-1", other.gameObject.transform.position);
                }
            }

            other.gameObject.AddComponent <KillActor>();
            break;
        }

        case ActionManager.AttackResult.VictimInfected:
        {
            SpawnStatusChange("+1", other.gameObject.transform.position);
            other.gameObject.AddComponent <InfectActor>();
            break;
        }

        case ActionManager.AttackResult.VictimOkay:
            break;

        case ActionManager.AttackResult.InfectionInProgress:
            //Tell the other character they're being infected by us
            //NOTE: No longer how infection works
            //othersStats.BeingInfectedBy = CallingGameObject;
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }