Ejemplo n.º 1
0
 private void Awake()
 {
     Character = GetComponent <AIBody>();
 }
Ejemplo n.º 2
0
    public float TimeToTarget; // Over which to achieve a target speed

    public void Awake()
    {
        Character = GetComponent <AIBody>();
    }
Ejemplo n.º 3
0
    private void GetFlagUpdate()
    {
        IsFlagChaser = true;

        Body.GetComponent <Renderer>().material = FlagRoleMaterial;

        if (ClosestEnemyInRange != null && CurrentBase == ClosestEnemyInRange.Team)
        {
            if (!IsCarryingFlag)
            {
                RemoveFlagChaserRole();
                CurrentAction = CTFActions.EvadeEnemy;
                DetermineActionUpdate();
                return;
            }
            else
            {
                CurrentAction = CTFActions.EvadeEnemy;
                Target        = ClosestEnemyInRange;
                DetermineActionUpdate();
                return;
            }
        }

        if (IsCarryingFlag)
        {                      // Head on home! To Victory!
            TargetFlag.transform.position = transform.position;
            Target = HomeBase; // replace with closest point, needs architectural update :(

            switch (Team)
            {
            case Teams.Red:
                RedFlagSeekerActiveWithFlag = true;
                break;

            case Teams.Blue:
                BlueFlagSeekerActiveWithFlag = true;
                break;

            case Teams.Green:
                GreenFlagSeekerActiveWithFlag = true;
                break;

            case Teams.Neutral:
                break;
            }

            float distanceFromGoal = (new Vector3(HomeBase.transform.position.x, transform.position.y, HomeBase.transform.position.z) - transform.position)
                                     .magnitude;
            if (distanceFromGoal <= 1f)
            {
                FlagBroughtHome();
            }
        }
        else
        { // Find the flag
            GameObject[] flags = GameObject.FindGameObjectsWithTag("flag");
            flags      = flags.Where(flag => flag.GetComponent <Flag>().Team != Team).ToArray();
            TargetFlag = flags[0].GetComponent <AIBody>();
            Target     = TargetFlag;

            switch (Team)
            {
            case Teams.Red:
                RedFlagSeekerActiveWithFlag = false;
                break;

            case Teams.Blue:
                BlueFlagSeekerActiveWithFlag = false;
                break;

            case Teams.Green:
                GreenFlagSeekerActiveWithFlag = false;
                break;

            case Teams.Neutral:
                break;
            }

            Vector3 distanceFromFlag = transform.position - Target.transform.position;
            distanceFromFlag.y = 0;

            if (distanceFromFlag.magnitude < SteppingRadius)
            {
                IsCarryingFlag = true;
            }
        }

        SteeringBehaviourSelection    = SteeringBehaviourSelection.SteeringArrive;
        KinematicBehaviourSelection   = KinematicBehaviourSelection.KinematicArrive;
        OrientationBehaviourSelection = OrientationBehaviourSelection.SteeringFace;
        HumanHeuristicMode            = HumanHeuristicMode.ReachingATarget;
    }