Пример #1
0
 private bool isInSelectedList(mainCharacter4 currentHero)
 {
     bool isSelected = false;
     foreach (mainCharacter4 hero in selected)
     {
         if (hero == currentHero)
             isSelected = true;
     }
     return isSelected;
 }
Пример #2
0
 // Update is called once per frame
 void Update()
 {
     spawningTimer += Time.deltaTime;
     if (spawningTimer >= spawnMax)
     {
         Debug.Log("New Orc unit is ready !");
         spawningTimer = 0.0f;
         mainCharacter4 newOne = Instantiate(orc);
         newOne.transform.position = new Vector2(-3.7f, 1.7f);
         omanage.heroes.Add(newOne);
     }
 }
Пример #3
0
 // Update is called once per frame
 void Update()
 {
     spawningTimer += Time.deltaTime;
     if (spawningTimer >= spawnMax)
     {
         Debug.Log("New Human unit is ready !");
         spawningTimer = 0.0f;
         mainCharacter4 newOne = Instantiate(human);
         newOne.transform.position = new Vector2(6.7f, -1.5f);
         //humanManage4.heroes.Add(newOne);
         omanage.heroes.Add(newOne);
     }
 }
Пример #4
0
    private bool isInSelectedList(mainCharacter4 currentHero)
    {
        bool isSelected = false;

        foreach (mainCharacter4 hero in selected)
        {
            if (hero == currentHero)
            {
                isSelected = true;
            }
        }
        return(isSelected);
    }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        timerDamge += Time.deltaTime;
        if (timerDamge >= timerDamageMax)
        {
            if (goal && humanToAttack != null) {
                humanToAttack.takeDamage(this.damage);
                Debug.Log("Human Unit [" + humanToAttack.pv + "/20] has been attacked");
            } else if (goal && buildToAttack != null) {
                buildToAttack.takeDamage(this.damage);
                Debug.Log("Human Buildiing [" + buildToAttack.pv + "/" + buildToAttack.pvMax + "] has been attacked");
            }
            timerDamge = 0;
        }

        if (humanToAttack == null && buildToAttack == null)
            goal = false;

        if (goal)
            anim.SetBool ("attacking", true);
        else
            anim.SetBool("attacking", false);

        if (this.pv <= 0) {
            this.pv = 0;
            anim.SetBool("dead", true);
        } else {
            anim.SetBool("dead", false);
        }

        // goes to position for goal
        if (this.humanToAttack != null && this.goal == false) {
            setDirection(humanToAttack.transform.position);
        } else if(this.buildToAttack != null && goal == false) {
            setDirection(buildToAttack.transform.position);
        }

        // reset target if dead
        if (humanToAttack != null && humanToAttack.pv <= 0) {
            humanToAttack.GetComponent<BoxCollider2D>().size = Vector2.zero;
            humanToAttack = null;
            goal = false;
        }
        if (buildToAttack != null && buildToAttack.pv <= 0) {
            buildToAttack = null;
            goal = false;
        }

        if(!Mathf.Approximately(rb.position.magnitude, direction.magnitude)) {
            gameObject.transform.position = Vector3.Lerp (gameObject.transform.position, direction, 1 / (15.0f * (Vector3.Distance (gameObject.transform.position, direction))));
            if (!goal)
                anim.SetBool ("walking", true);
        } else {
            anim.SetBool ("walking", false);
            transform.localScale = new Vector3(1, 1, 1);
        }
    }
Пример #6
0
    // Update is called once per frame
    void Update()
    {
        timerDamge += Time.deltaTime;
        if (timerDamge >= timerDamageMax)
        {
            if (goal && humanToAttack != null)
            {
                humanToAttack.takeDamage(this.damage);
                Debug.Log("Human Unit [" + humanToAttack.pv + "/20] has been attacked");
            }
            else if (goal && buildToAttack != null)
            {
                buildToAttack.takeDamage(this.damage);
                Debug.Log("Human Buildiing [" + buildToAttack.pv + "/" + buildToAttack.pvMax + "] has been attacked");
            }
            timerDamge = 0;
        }

        if (humanToAttack == null && buildToAttack == null)
        {
            goal = false;
        }

        if (goal)
        {
            anim.SetBool("attacking", true);
        }
        else
        {
            anim.SetBool("attacking", false);
        }

        if (this.pv <= 0)
        {
            this.pv = 0;
            anim.SetBool("dead", true);
        }
        else
        {
            anim.SetBool("dead", false);
        }

        // goes to position for goal
        if (this.humanToAttack != null && this.goal == false)
        {
            setDirection(humanToAttack.transform.position);
        }
        else if (this.buildToAttack != null && goal == false)
        {
            setDirection(buildToAttack.transform.position);
        }

        // reset target if dead
        if (humanToAttack != null && humanToAttack.pv <= 0)
        {
            humanToAttack.GetComponent <BoxCollider2D>().size = Vector2.zero;
            humanToAttack = null;
            goal          = false;
        }
        if (buildToAttack != null && buildToAttack.pv <= 0)
        {
            buildToAttack = null;
            goal          = false;
        }

        if (!Mathf.Approximately(rb.position.magnitude, direction.magnitude))
        {
            gameObject.transform.position = Vector3.Lerp(gameObject.transform.position, direction, 1 / (15.0f * (Vector3.Distance(gameObject.transform.position, direction))));
            if (!goal)
            {
                anim.SetBool("walking", true);
            }
        }
        else
        {
            anim.SetBool("walking", false);
            transform.localScale = new Vector3(1, 1, 1);
        }
    }