Exemple #1
0
 public override void FinishDecision(MAnimalBrain brain, int Index)
 {
     //Reset all variables
     Bool  = null;
     Int   = null;
     Float = null;
 }
Exemple #2
0
    private void OnEnable()
    {
        rb = GetComponent <Rigidbody>();
        bb = GetComponent <Blackboard>();

        visionRangeObject = bb.GetGameObjectVar("visionRange").Value;
        healRangeObject   = bb.GetGameObjectVar("healRange").Value;

        iWasJustPanicking = bb.GetBoolVar("wasIPanicking");

        inMotion       = bb.GetBoolVar("inMotion");
        inMotion.Value = false;

        turnSpeed = bb.GetFloatVar("turnSpeed");
        moveSpeed = bb.GetFloatVar("moveSpeed");

        healTimeInSeconds = bb.GetFloatVar("healSpeedInSeconds");

        targettedFriend = bb.GetGameObjectVar("healTarget");

        if (targettedFriend.Value != null)
        {
            lowestHPRatio = targettedFriend.Value.GetComponent <HPValueHandler>().myHP / targettedFriend.Value.GetComponent <HPValueHandler>().maxHP;
        }
    }
Exemple #3
0
 private void Awake()
 {
     //Getting all require components
     agent      = GetComponent <UnityEngine.AI.NavMeshAgent>();
     energyVar  = blackboard.GetFloatVar("energy");
     playerVar  = blackboard.GetGameObjectVar("player");
     cubeVar    = blackboard.GetGameObjectVar("cube");
     sphereVar  = blackboard.GetGameObjectVar("sphere");
     officerVar = blackboard.GetGameObjectVar("officer");
 }
Exemple #4
0
        void Reset()
        {
            MalbersTools.SetLayer(transform, 20);     //Set all the Childrens to Animal Layer   .
            gameObject.tag = "Animal";                //Set the Animal to Tag Animal
            AnimatorSpeed  = 1;

            Anim = GetComponentInParent <Animator>();           //Cache the Animator
            RB   = GetComponentInParent <Rigidbody>();          //Catche the Rigid Body

            if (RB == null)
            {
                RB                        = gameObject.AddComponent <Rigidbody>();
                RB.useGravity             = false;
                RB.constraints            = RigidbodyConstraints.FreezeRotation;
                RB.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
            }

            speedSets = new List <MSpeedSet>(1)
            {
                new MSpeedSet()
                {
                    name = "Ground",
                    StartVerticalIndex = new Scriptables.IntReference(1),
                    TopIndex           = new Scriptables.IntReference(2),
                    states             = new  List <StateID>(2)
                    {
                        MalbersTools.GetInstance <StateID>("Idle"), MalbersTools.GetInstance <StateID>("Locomotion")
                    },
                    Speeds = new  List <MSpeed>(3)
                    {
                        new MSpeed("Walk", 1, 4, 4), new MSpeed("Trot", 2, 4, 4), new MSpeed("Run", 3, 4, 4)
                    }
                }
            };

            BoolVar  useCameraInp = MalbersTools.GetInstance <BoolVar>("Global Camera Input");
            BoolVar  globalSmooth = MalbersTools.GetInstance <BoolVar>("Global Smooth Vertical");
            FloatVar globalTurn   = MalbersTools.GetInstance <FloatVar>("Global Turn Multiplier");

            if (useCameraInp != null)
            {
                useCameraInput.Variable = useCameraInp;
            }
            if (globalSmooth != null)
            {
                SmoothVertical.Variable = globalSmooth;
            }
            if (globalTurn != null)
            {
                TurnMultiplier.Variable = globalTurn;
            }

            CalculateHeight();
        }
Exemple #5
0
 /// <summary>Modify Stat Value instantly (Add/Remove to the Value)</summary>
 public virtual void _PinStatModifyValue(FloatVar value)
 {
     if (PinnedStat != null)
     {
         PinnedStat.Modify(value.Value);
     }
     else
     {
         Debug.Log("There's no Pinned Stat");
     }
 }
Exemple #6
0
        public virtual void Invoke(FloatVar value)
        {
            float val = value;

            for (int i = eventListeners.Count - 1; i >= 0; i--)
            {
                eventListeners[i].OnEventInvoked(val);
            }

            DebugEvent(value);
        }
Exemple #7
0
    void OnEnable()
    {
        //get blackboard vars for hp and max hp
        myHP  = GetComponent <Blackboard>().GetFloatVar("hpValue");
        maxHP = GetComponent <Blackboard>().GetFloatVar("hpMax");

        //stop trying to overheal the character blackboard user
        if (myHP.Value > maxHP.Value)
        {
            myHP.Value = maxHP.Value;
        }
    }
Exemple #8
0
    // Called when the state is enabled
    void OnEnable()
    {
        rb = GetComponent <Rigidbody>();
        bb = GetComponent <Blackboard>();

        turnSpeed   = bb.GetFloatVar("turnSpeed");
        attackSpeed = bb.GetFloatVar("attackSpeedInSeconds");

        attackRangeObject = bb.GetGameObjectVar("attackRange").Value.GetComponent <ScanSightArea>();

        inMotion       = bb.GetBoolVar("inMotion");
        amIAtObjective = bb.GetBoolVar("atObjective");
    }
Exemple #9
0
    private void OnEnable()
    {
        rb = GetComponent <Rigidbody>();
        bb = GetComponent <Blackboard>();

        turnSpeed = bb.GetFloatVar("turnSpeed");
        moveSpeed = bb.GetFloatVar("moveSpeed");

        visionRangeObject = bb.GetGameObjectVar("visionRange").Value.GetComponent <ScanSightArea>();

        inMotion = bb.GetBoolVar("inMotion");

        Invoke("GetAPositionToMoveTo", Time.maximumDeltaTime);
    }
Exemple #10
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            EditorGUILayout.Space();

            FloatVar var = EditorGUILayout.ObjectField("Slider Variable", sliderTarget.SliderVar, typeof(FloatVar), false) as FloatVar;

            if (var != sliderTarget.SliderVar)
            {
                sliderTarget.SliderVar = var;
                EditorUtility.SetDirty(sliderTarget);
            }
        }
Exemple #11
0
    private void OnEnable()
    {
        rb = GetComponent <Rigidbody>();
        bb = GetComponent <Blackboard>();

        targettedFriend = bb.GetGameObjectVar("healTarget");

        visionRangeObject = bb.GetGameObjectVar("visionRange").Value.GetComponent <ScanSightArea>();
        healRangeObject   = bb.GetGameObjectVar("healRange").Value.GetComponent <ScanSightArea>();

        iWasJustPanicking = bb.GetBoolVar("wasIPanicking");
        inMotion          = bb.GetBoolVar("inMotion");

        turnSpeed = bb.GetFloatVar("turnSpeed");
        moveSpeed = bb.GetFloatVar("moveSpeed");

        lowestHPRatio = 2;
    }
Exemple #12
0
        /// <summary>
        /// Draw a float variable.
        /// <param name="rect">The position to draw the variable.</param>
        /// <param name="floatVar">The float variable to be drawn.</param>
        /// </summary>
        static void DrawFloatVar(Rect rect, FloatVar floatVar)
        {
            rect.yMin += 3f;
            rect.yMax -= 2f;
            rect.xMin += 6f;
            rect.xMax -= 6f;

            DrawName(new Rect(rect.x, rect.y, c_LargeNameWidth, rect.height), floatVar);

            rect.xMin += c_LargeNameWidth + c_Space;
            rect.xMax -= c_MinusButtonWidth + c_RightPadding;
            EditorGUI.BeginChangeCheck();
            var newValue = EditorGUI.FloatField(rect, GUIContent.none, floatVar.Value);

            if (EditorGUI.EndChangeCheck() && newValue != floatVar.Value)
            {
                // Register undo
                if (floatVar.blackboard != null)
                {
                    #if UNITY_4_0_0 || UNITY_4_1 || UNITY_4_2
                    Undo.RegisterUndo(floatVar.blackboard, "Variable Value");
                    #else
                    Undo.RecordObject(floatVar.blackboard, "Variable Value");
                    #endif
                }

                // Update variable value
                floatVar.Value = newValue;
                // Set blackboard dirty flag
                if (floatVar.blackboard != null)
                {
                    EditorUtility.SetDirty(floatVar.blackboard);
                }
            }

            rect.x    += rect.width + 2f;
            rect.width = c_MinusButtonWidth;
            rect.yMin -= 2f;
            rect.yMax += 2f;
            if (GUI.Button(rect, s_Styles.iconToolbarMinus, s_Styles.invisbleButton))
            {
                s_VariableToRemove = floatVar;
            }
        }
Exemple #13
0
    private void OnEnable()
    {
        rb = GetComponent <Rigidbody>();
        bb = GetComponent <Blackboard>();

        visionRangeObject = bb.GetGameObjectVar("visionRange").Value;

        maxTimeUntilRotation = bb.GetFloatVar("rotationTimeMax");
        minTimeUntilRotation = bb.GetFloatVar("rotationTimeMin");

        bb.GetBoolVar("wasIPanicking").Value = true;

        turnSpeed = bb.GetFloatVar("turnSpeed");
        moveSpeed = bb.GetFloatVar("moveSpeed");

        newRotationVector = new Vector3(Random.Range(-180, 180), transform.position.y, Random.Range(-180, 180));

        GetComponentInChildren <ParticleSystem>().Play();
    }
Exemple #14
0
    private void OnEnable()
    {
        rb = GetComponent <Rigidbody>();
        bb = GetComponent <Blackboard>();

        moveSpeed   = bb.GetFloatVar("moveSpeed");
        turnSpeed   = bb.GetFloatVar("turnSpeed");
        attackSpeed = bb.GetFloatVar("attackSpeedInSeconds");

        visionRangeObject = bb.GetGameObjectVar("visionRange").Value.GetComponent <ScanSightArea>();
        attackRangeObject = bb.GetGameObjectVar("attackRange").Value.GetComponent <ScanSightArea>();

        inMotion       = bb.GetBoolVar("inMotion");
        amIAtObjective = bb.GetBoolVar("atObjective");

        targettedEnemy = bb.GetGameObjectVar("targetEnemy");

        invokedTeleport = false;
        invokeScan      = false;
    }
Exemple #15
0
 public void SetValue(FloatVar value)
 {
     Value = value.Value;
 }
    public FloatVar damage; // Stores the amount of damage.

    // This function is called to reset the default values of the node
    public override void Reset()
    {
        base.Reset();   // Reset the enabled property
        this.damage = new ConcreteFloatVar();
    }
 public EventArgs(float oldValue, float value, FloatVar scriptableFloat)
 {
     OldValue = oldValue;
     NewValue = value;
     Float    = scriptableFloat;
 }
Exemple #18
0
 /// <summary>
 /// Procura e retorna em caso de sucesso uma variavel de gráfico do tipo <see cref="FloatVar"/>
 /// </summary>
 /// <param name="variable">Nome da variavel</param>
 /// <param name="floatVar">Se encontrado o objeto resultante <see cref="FloatVar"/> será alocado nele.</param>
 /// <returns>Verdadeiro se encontrado, falso se não encontrado</returns>
 public bool TryGetFloatValue(string variable, out FloatVar floatVar)
 {
     return(floatVars.TryGetValue(variable, out floatVar));
 }
Exemple #19
0
 private void Awake()
 {
     canisterVar = blackboard.GetGameObjectVar("canister");
     energyVar   = blackboard.GetFloatVar("energy");
     _agent      = GetComponent <NavMeshAgent>();
 }
Exemple #20
0
 public void ApplyChange(FloatVar amount)
 {
     value += amount.value;
 }
Exemple #21
0
 // Use this for initialization
 public override void Reset()
 {
     power = new ConcreteFloatVar();
     text  = new ConcreteStringVar();
 }
Exemple #22
0
 private void Awake()
 {
     energyVar = blackboard.GetFloatVar("energy"); //Needed for other states
 }
Exemple #23
0
 /// <summary>Modify Stat Value instantly (Add/Remove to the Value)</summary>
 public virtual void Stat_Pin_ModifyValue(FloatVar value)
 {
     PinnedStat?.Modify(value.Value);
 }
Exemple #24
0
 /// <summary>Modify Stat Value instantly (Add/Remove to the Value)</summary>
 public virtual void Stat_Pin_SetMult(FloatVar value)
 {
     PinnedStat?.SetMultiplier(value.Value);
 }
 private void CreateFloat() => Float = (FloatVar)MTools.CreateScriptableAsset(typeof(FloatVar));