Пример #1
0
    /// <summary>
    /// Generates weapon behaviour chains for all players.
    /// </summary>
    public void GenerateNewBehaviours()
    {
        Debug.Log("New behaviours generated with weight of: " + currentBaseWeaponWeight);

        // Empty the generated behaviours dictionary to make room for new ones.
        generatedBehavioursDict.Clear();

        // Generate a behaviour chain for each player in the game.
        foreach (LocalPlayerController player in GameData.players)
        {
            if (player != null)
            {
                // Reset values prior to generating new ones.
                ResetValues(weaponBehaviourDict);

                // Generate behaviour values.
                Queue <BehaviourWeight> behavioursToGenerate = CalculateBehaviours(player);

                // The base behaviour to assign to this player's weapon later.
                // Assign default shooting behaviour in case no specific behaviours were selected.
                WeaponBehaviour baseBehaviour = new DefaultBehaviour(player.playerIndex, defaultBehaviourSettings, null);

                // Make sure at least one behaviour was selected.
                if (behavioursToGenerate.Count > 0)
                {
                    // Generate ordered behaviour chain from selected behaviours.
                    baseBehaviour = GenerateBehaviourChain(player.playerIndex, behavioursToGenerate);
                }

                // Cache behaviour with player ID until weapons are generated and behaviours can be attached.
                generatedBehavioursDict.Add(player.playerIndex, baseBehaviour);
            }
        }
    }
Пример #2
0
        /// <summary>
        /// Configures the spy to do nothing. This is also the default behaviour
        /// for a new spy and results in a default value being returned if the
        /// method is a function.
        /// </summary>
        /// <returns>The spy.</returns>
        public SpyWithBehaviour DoNothing()
        {
            ConstrainPreviousBehaviour();
            var behaviour = new DefaultBehaviour();

            behaviour.ParameterChangesBeforeExecution = _parameterChanges;
            _spy.Behaviours.Enqueue(behaviour);
            return(new SpyWithBehaviour(_spy, behaviour));
        }
Пример #3
0
        /// <summary>
        /// Configures the spy to do nothing. This is also the default behaviour
        /// for a new spy and results in a default value being returned if the
        /// method is a function.
        /// </summary>
        /// <returns>The spy.</returns>
        public SpyWithBehaviour DoNothing()
        {
            _spy.Behaviours.Clear();
            var behaviour = new DefaultBehaviour();

            behaviour.UpdateLifetime(int.MaxValue);
            behaviour.ParameterChangesBeforeExecution = _parameterChanges;
            _spy.Behaviours.Enqueue(behaviour);
            return(new SpyWithBehaviour(_spy, behaviour));
        }
Пример #4
0
        private Spy(MethodInfo method, object key)
        {
            Method = method;
            Key    = key;

            // setup up spy to only return a default value forever
            var defaultBehaviour = new DefaultBehaviour();

            defaultBehaviour.UpdateLifetime(int.MaxValue);
            Behaviours.Enqueue(defaultBehaviour);
        }
Пример #5
0
    public Vehicle_Plane(GameObject vehicleObject, GameObject targetObject)
    {
        vehicleObj = vehicleObject;
        behaviour  = new DefaultBehaviour(this);

        this.targetObject = targetObject;

        maxSpeed     = 1000.0f;
        maxForce     = 250.0f;
        maxRollRate  = 45.0f;
        maxPitchRate = 30.0f;

        minForce = -100.0f;
    }