public int Tooled(int toolID)
 {
     if (_rState == RaptorState.FiddlingWithComputer)
     {
         if (toolID == 0)
         {
             _rState = RaptorState.HeadingToTarget;
             targettedComputer.RaptorInterferenceInterferedWith();
             playRaptorSound();
             targettedComputer = null;
             targettedLocation = null;
             return(0);
         }
         else if (toolID == 1)
         {
             _rState = RaptorState.Learning;
             pBar.gameObject.SetActive(true);
             _RaptorTimer = timeToEducate;
             if (targettedComputer != null)                          //If raptor finishes fiddling after you've brought up the raptor tool panel but before you selected an option.  Should make the panel disappear and adjust the player state when the raptor moves rather than leaving the player still able to press a button, but I'll get to that later perhaps.
             {
                 targettedComputer.RaptorInterferenceInterferedWith();
             }
             targettedComputer = null;
             targettedLocation = null;
             return(1);
         }
         return(-1);
     }
     else
     {
         return(-1);
     }
 }
 public void ArrivedAtLocation()
 {
     _rState           = RaptorState.WastingTime;
     _RaptorTimer      = laziness;
     targettedLocation = null;
     targettedComputer = null;
 }
 // Start is called before the first frame update
 void Start()
 {
     _rState = RaptorState.Imprisoned;
     CM      = FindObjectOfType <ComputerManager> ();
     AS      = GetComponent <AudioSource> ();
     nonComputerLocations = FindObjectsOfType <NonComputer> ();
     _RaptorTimer         = 0f;
 }
    // Update is called once per frame
    void Update()
    {
        _RaptorTimer -= Time.deltaTime;

        if (_RaptorTimer < 0 && _rState == RaptorState.WastingTime)
        {
            playRaptorSound();
            _rState = RaptorState.HeadingToTarget;
        }

        if (_rState == RaptorState.HeadingToTarget)
        {
            if (targettedLocation == null)
            {
                FindNewTarget();
            }
            else
            {
                if (targettedComputer != null)
                {
                    if (targettedComputer._state != Computer.ComputerState.WaitingToCrash)
                    {
                        FindNewTarget();
                    }
                }
            }
        }
        else if (_rState == RaptorState.Learning)
        {
            pBar.progress = ((timeToEducate - _RaptorTimer) / timeToEducate) * 100;
            if (_RaptorTimer < 0)
            {
                playRaptorSound();
                _rState = RaptorState.Content;
                pBar.gameObject.SetActive(false);
                raptorAgent.SetDestination(RaptorHappyPlace.gameObject.transform.position);
                targettedComputer = RaptorHappyPlace;
                targettedLocation = RaptorHappyPlace.gameObject;
                // Need to tell the player that the lesson is over.
                FindObjectOfType <PlayerControl> ().LessonOver();
            }
        }
    }
Ejemplo n.º 5
0
        void PerformBehavior()
        {
            if (this.IsDead())
            {
                return;
            }

            if (enemy == null || enemy.IsDead())
            {
                AcquireEnemy();
            }
            float distanceToTarget = float.PositiveInfinity;
            Vector3 targetVec = Vector3.Forward;
            animationDelay -= Time.GameTime.ElapsedTime;

            if (enemy != null)
            {

                targetVec = enemy.Transformation.GetPosition() - this.Transformation.GetPosition();
                distanceToTarget = targetVec.Length();
                targetVec *= 1.0f / distanceToTarget; //Normalize the vector
            }

            switch (state)
            {
                case RaptorState.Wander:
                    if (distanceToTarget < SIGHT_DISTANCE)
                        // Change state
                        state = RaptorState.Chase;
                    else
                        Wander();
                    break;

                case RaptorState.Chase:
                    if (distanceToTarget <= ATTACK_DISTANCE)
                    {
                        // Change state
                        state = RaptorState.Attack;
                        wanderDelayTime = 0;
                    }
                    if (distanceToTarget > SIGHT_DISTANCE * 1.35f)
                        state = RaptorState.Wander;
                    else if (distanceToTarget > MIN_ATTACK_DISTANCE)
                    {
                        Move(targetVec);
                    }
                    else
                    {
                        Move(-targetVec);
                    }
                    break;

                case RaptorState.Attack:
                    if (distanceToTarget > ATTACK_DISTANCE * 1.5f)// || distanceToTarget < MIN_ATTACK_DISTANCE)
                    {
                        state = RaptorState.Chase;
                    }
                    else
                    {
                        if(distanceToTarget > ATTACK_DISTANCE)
                            Move(targetVec);
                        state = RaptorState.Attack;
                        if (animationDelay <= 0.0f)
                        {
                            enemy.ApplyDamage(datablock.Damage);
                        }
                        //Attack
                    }
                    break;

                default:
                    break;
            }
        }
Ejemplo n.º 6
0
        protected override void ResetState()
        {
            base.ResetState();
            wanderMovesCount = 0;
            // Unit configurations
            enemy = null;

            wanderPosition = Transformation.GetPosition();
            wanderStartPosition = wanderPosition;
            state = RaptorState.Wander;
        }
Ejemplo n.º 7
0
 protected override void OnDeath()
 {
     base.OnDeath();
     state = RaptorState.Dead;
     velocityVector = Vector3.Zero;
 }
Ejemplo n.º 8
0
 void SetState(RaptorState newState)
 {
     prevState = state;
     state = newState;
 }
Ejemplo n.º 9
0
 void AcquireEnemy()
 {
     enemy = null;
     float minDist = float.PositiveInfinity;
     for (int i = 0; i < scene.Actors.Count; i++)
     {
         Actor currActor = scene.Actors[i];
         if (currActor.GetTeam() != this.GetTeam() && !currActor.IsDead())
         {
             float dist = Vector3.DistanceSquared(currActor.Transformation.GetPosition(), this.Transformation.GetPosition());
             if (dist < minDist)
             {
                 enemy = currActor;
                 minDist = dist;
             }
         }
     }
     if (enemy != null)
     {
         state = RaptorState.AquiredTarget;
         //Roar when they're spotted
         string attackAnim = datablock.GetAnimation(DinosaurAnimationsSimple.Roar);
         new Sound3D(datablock.RoarSoundEffect, this.Transformation.GetPosition());
         model.GetAnimationLayer().AddAnimation(attackAnim, true);
         animationDelay = ResourceManager.Inst.GetAnimation(attackAnim).EndTime;
     }
     else
         state = RaptorState.Wander;
 }
Ejemplo n.º 10
0
 protected override void OnDeath()
 {
     base.OnDeath();
     state = RaptorState.Dead;
     velocityVector = Vector3.Zero;
     new Sound3D(datablock.DeathSoundEffect, this.Transformation.GetPosition());
     model.GetAnimationLayer().SetActiveAnimation(datablock.GetAnimation(DinosaurAnimationsSimple.DeathIdle), false);
     string deathAnim = datablock.GetAnimation(DinosaurAnimationsSimple.Death);
     model.GetAnimationLayer().AddAnimation(deathAnim, true);
     deathAnimationTime = ResourceManager.Inst.GetAnimation(deathAnim).EndTime;
     grounding.SetPosition(datablock.DeathPosition);
     grounding.SetRotation(datablock.DeathRotation);
 }