예제 #1
0
        /// <summary>
        /// Heads towards the current distraction
        /// </summary>
        private bool headToDistraction(Script_ZombieZone.ZombieDistraction distract)
        {
            bool bClearPath = Helpers.calcBresenhemsPredicate(_arena,
                                                              _state.positionX, _state.positionY, distract.x, distract.y,
                                                              delegate(LvlInfo.Tile t)
            {
                return(!t.Blocked);
            }
                                                              );

            if (!bClearPath)
            {
                return(false);
            }

            //It's clear, let's steer towards it
            Vector3 distractpos = new Vector3(((float)distract.x) / 100.0, ((float)distract.y) / 100.0, 0);

            steering.steerDelegate = delegate(InfantryVehicle vehicle)
            {
                Vector3 wander = vehicle.SteerForWander(10.5f);
                Vector3 seek   = vehicle.SteerForSeek(distractpos);
                return(wander + (seek * 10.8f));
            };

            if (distract.bStillHostile && _weapon.bEquipped && victim != null)
            {   //Can we shoot?
                if (_weapon.ableToFire())
                {
                    int aimResult = _weapon.getAimAngle(victim._state);

                    if (_weapon.isAimed(aimResult))
                    {   //Spot on! Fire?
                        _itemUseID = _weapon.ItemID;
                        _weapon.shotFired();
                    }

                    steering.bSkipAim = true;
                    steering.angle    = aimResult;
                }
                else
                {
                    steering.bSkipAim = false;
                }
            }

            return(true);
        }
예제 #2
0
        /// <summary>
        /// Checks for any distractions we should approach
        /// </summary>
        protected virtual bool checkForDistractions(Script_ZombieZone.TeamState state)
        {       //Do we already have a distraction?
            if (distraction != null)
            {
                if (distraction.bActive)
                {
                    if (!headToDistraction(distraction))
                    {
                        distraction = null;
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    distraction = null;
                }
            }

            //Are there any distractions we can see?
            foreach (Script_ZombieZone.ZombieDistraction distract in state.distractions)
            {   //At it's limit?
                if (distract.distractLimit <= 0)
                {
                    continue;
                }

                //If it works, use it
                if (headToDistraction(distract))
                {
                    distraction = distract;
                    distract.distractLimit--;
                    return(true);
                }
            }

            return(false);
        }