Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        chcount = chcount + 1;
        if (chcount >= checkdistevery)
        {
            if (Player)
            {
                //GET DISTANCE
                float dist = Vector3.Distance(transform.position, Player.transform.position);
                //GET AI COMPONENT
                FreeAI AI = (FreeAI)GetComponent("FreeAI");


                //WHEN DISTANCE BECOMES LESS THE ACTIVATE DISTANCE
                if (dist <= DistanceToActivateAI)
                {
                    if (AI.enabled)
                    {
                    }
                    else
                    {
                        AI.enabled = true;
                    }
                    if (GetComponent <Rigidbody>().isKinematic)
                    {
                        GetComponent <Rigidbody>().isKinematic = false;
                    }
                }
                else
                {
                    if (GetComponent <Rigidbody>().isKinematic)
                    {
                    }
                    else
                    {
                        GetComponent <Rigidbody>().isKinematic = true;
                    }

                    if (AI.enabled)
                    {
                        AI.enabled = false;
                    }
                    if (PlayIdleAnimationWhenDeactive)
                    {
                        if (AI.IsDead)
                        {
                        }
                        else
                        {
                            if (AI.IdleAnimation)
                            {
                                AI.AICharacter.GetComponent <Animation>().CrossFade(idle.name, 0.12f);
                            }
                        }
                    }
                }
            }
            chcount = 0;
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        //Matts version of melee damage (missing parts)

        /*onCollisionEnter(Collider "MeleeCollide"){
         *      if("MeleeCollide" == type && mousePressed(1) || mousePressed(2){
         *              CurrentHealth = CurrentHealth - Random.Range(0,5);
         *      }*/
        //IF INVINCIBLE, HE CANNOT DIE..
        if (Invincible)
        {
            CurrentHealth = MaxHealth;
        }
        else if (CurrentHealth <= 0)
        {
            CurrentHealth = 0;
            Dead          = true;
        }

        //MAX HEALTH
        if (CurrentHealth >= MaxHealth)
        {
            CurrentHealth = MaxHealth;
        }

        //WHEN DEATH IS UPON HIM
        if (Dead)
        {
            //TELL THE AI SCRIPT HE IS DEAD
            FreeAI AI = (FreeAI)GetComponent("FreeAI");
            if (AI)
            {
                if (AI.IsDead)
                {
                }
                else
                {
                    AI.IsDead = true;
                }
            }
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        //IF INVINCIBLE, HE CANNOT DIE..
        if (Invincible)
        {
            CurrentHealth = MaxHealth;
        }
        else
        {
            if (CurrentHealth <= 0)
            {
                CurrentHealth = 0;
                Dead          = true;
            }

            //MAX HEALTH
            if (CurrentHealth >= MaxHealth)
            {
                CurrentHealth = MaxHealth;
            }

            //WHEN DEATH IS UPON HIM
            if (Dead)
            {
                //TELL THE AI SCRIPT HE IS DEAD
                FreeAI AI = (FreeAI)GetComponent("FreeAI");
                if (AI)
                {
                    if (AI.IsDead)
                    {
                    }
                    else
                    {
                        AI.IsDead = true;
                    }
                }
            }
        }
    }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        FreeAI AI = (FreeAI)GetComponent("FreeAI");

        idle = AI.IdleAnimation;
    }
Esempio n. 5
0
    void OnGUI()
    {
        if (currentTarget != null)
        {
            if (currentTarget.gameObject.tag == "NPC")
            {
                string stringToShow = currentTarget.gameObject.name.ToString();

                GUI.Box(new Rect(200, 30, 150, 25), "Target: " + stringToShow);
            }

            if (currentTarget.gameObject.tag == "Player")
            {
                PhotonView _otherPlayer = currentTarget.GetComponent <PhotonView> ();

                string _otherPlayersName = _otherPlayer.owner.name.ToString();

                GUI.Box(new Rect(200, 30, 150, 25), "Target: " + _otherPlayersName);
            }

            if (currentTarget.gameObject.tag == "Enemy")
            {
                FreeAI _theAI = currentTarget.GetComponent <FreeAI> ();

                string _enemyName = _theAI.EnemysName;

                GUI.Box(new Rect(200, 30, 150, 25), "Target: " + _enemyName);
            }


            _targetRange = Mathf.Round(_targetRange * 100.0f) / 100.0f;

            if (_targetRange < 0)
            {
                _targetRange = _targetRange * -1;
            }

            GUI.Box(new Rect(200, 60, 150, 25), "Range: " + _targetRange);
        }


        //GUI.Box(new Rect(1, 60, 150, 25), "Health: " + _PlayerHealth);
        GUI.Box(new Rect(1, 30, 120, 25), photonView.owner.name);
        GUI.Box(new Rect(10, 60, 100, 25), "Health: " + _healthScript.health);
        GUI.Box(new Rect(10, 90, 100, 25), "Bullets: " + _bullets);
        GUI.Box(new Rect(10, 120, 100, 25), "Stamina: " + _stamina);



        if (GUI.Button(new Rect((Screen.width / 2) - 55, (Screen.height - 55), 50, 50), "1 \n" + _buttonOne_label + "\n " + spell_1_cd))
        {
            Spell(1);
        }

        if (GUI.Button(new Rect((Screen.width / 2), (Screen.height - 55), 50, 50), "2 \n" + _buttonTwo_label + "\n " + spell_2_cd))
        {
            Spell(2);
        }

        if (GUI.Button(new Rect((Screen.width / 2) + 55, (Screen.height - 55), 50, 50), "3 \n" + _buttonThree_label + "\n " + spell_3_cd))
        {
            Spell(3);
        }

        if (_healthScript.health <= 0)
        {
            GUI.Box(new Rect(Screen.width / 2, Screen.height / 2, 120, 25), "You Died");

            if (GUI.Button(new Rect((Screen.width / 2), (Screen.height / 2) + 50, 120, 25), "Re Spawn?"))
            {
                photonView.RPC("reSpawn", PhotonTargets.AllBuffered);
            }
        }
    }