Exemple #1
0
 void Start()
 {
     anim              = GetComponentInChildren <Animator>();
     guardScript       = GetComponent <Guard>();
     guardAttackScript = GetComponent <GuardAttack>();
     agent             = GetComponent <NavMeshAgent>();
     player            = GameObject.FindGameObjectWithTag("Player");
     guardManager      = GameObject.FindObjectOfType <GuardManager>();
 }
Exemple #2
0
    // Use this for initialization
    void Start()
    {
        foreach (Transform t in GameObject.FindGameObjectWithTag("targetPositions").transform)
        {
            if (t.name == "GeneratorRoom")
            {
                GeneratorRoom = t;
            }
            else if (t.name == "PrisonRoom")
            {
                Prison = t;
            }
            else if (t.name == "ExitRoom")
            {
                Exit = t;
            }
            else if (t.name == "RadiationRoom")
            {
                RadiationRoom = t;
            }
            else if (t.name == "Entrance")
            {
                Entrance = t;
            }
            else if (t.name == "HospitalRoom")
            {
                MedicalRoom = t;
            }
        }

        switch (currentCharacter)
        {
        case CharacterType.CIVILIAN:
            civState = CivilianState.IDLE;
            break;

        case CharacterType.RADIATED_PRISONER:
            rAttack = GetComponent <RadiatorAttack>();
            break;

        case CharacterType.RADIATED_PERSON:
            rAttack = GetComponent <RadiatorAttack>();
            break;

        case CharacterType.TECHNICIAN:
            break;

        case CharacterType.GUARD:
            gAttack = GetComponent <GuardAttack>();
            break;
        }
    }
        /// <summary>
        /// This function will process a MoveEvent and will make the unit "react" to that move event.
        /// </summary>
        /// <param name="unit">The Unit that observed the event.</param>
        /// <param name="gameEvent">The MoveEvent</param>
        /// <param name="gw">The GameWorld this is occurring in.</param>
        private static void handleMoveEventUnit(Unit unit, GameEvent gameEvent, GameWorld gw)
        {
            Console.Write("Unit at (" + unit.x + ", " + unit.y + "): ");
            // Check if unit caused this MoveEvent
            if (gameEvent.sourceEntity == (Entity)unit)
            {
                Unit target = searchCellsForEnemy(unit, gw);

                if (target != null)
                {
                    Console.WriteLine("See Enemy at " + target.getCell().Xcoord + ", (" + target.getCell().Ycoord + ")");
                }
            }

            // unit did not cause move event
            else
            {
                // Check if sourceEntity is an enemy
                if (unit.getOwner().isEnemy(gameEvent.sourceEntity.getOwner()))
                {
                    // Check if unit is in the Aggressive AttackStance
                    if (unit.getAttackStance() == Unit.AttackStance.Agressive)
                    {
                        if (isInterruptable(unit))
                        {
                            AttackAction attackAction = new AttackAction(unit, gameEvent.sourceEntity, gw);
                            ActionController.Instance.giveCommand(unit, attackAction);
                            Console.WriteLine("Aggressive attack the entity in cell: " + gameEvent.orginCell.Xcoord + ", " + gameEvent.orginCell.Ycoord + ")");
                        }
                    }

                    // Check if unit is in the Guard AttackStance
                    else if (unit.getAttackStance() == Unit.AttackStance.Guard)
                    {
                        GuardAttack guardAttack = new GuardAttack(unit, gameEvent.sourceEntity, gw);
                        ActionController.Instance.giveCommand(unit, guardAttack);
                        Console.WriteLine("Guard attack the entity in cell: " + gameEvent.orginCell.Xcoord + ", " + gameEvent.orginCell.Ycoord + ")");
                    }
                }
            }
        }