Пример #1
0
    /// <summary>
    /// Updates the bees every half second.
    /// </summary>
    IEnumerator ATTACK_ON_TITAN()
    {
        //float stepTime;
        //Debug.Log("Begin Moving");
        while (isAttacking)
        {
            /*if(Time.deltaTime < 0.03f)
             * {
             *      //Debug.Log("Update faster than 30fps, Delta time is: " + Time.deltaTime);
             *      stepTime = 0.03f;
             * }
             * else
             * {
             *      //Debug.Log ("Update Slower that 30fps, Delta time is: " + Time.deltaTime);
             *      stepTime = Time.deltaTime;
             * }*/
            //Debug.Log ("Attack");
            if (answerBall)
            {
                //Debug.Log("Ball Found");
                QBParent.position = Vector3.MoveTowards(QBParent.position, answerBall.transform.position, speed * 0.02f /*Time.deltaTime*/);                 //replaced 0.03f with Time.deltaTime. I'll explain it in detail if you don't know why 0.03f will not work
            }
            else
            {
                isAttacking = false;
            }
            //Debug.Log(Time.time);Debug.Log(Time.deltaTime);Debug.Log(Time.fixedDeltaTime);
            yield return(new WaitForSeconds(0.03f));
            //Debug.Log(Time.time);
        }
        MoveDir = BeeHivePos - transform.position;
        float dist = MoveDir.magnitude;

        MoveDir.Normalize();
        Vector3 moveStep;

        if (transform.eulerAngles.y < 180)
        {
            transform.eulerAngles += new Vector3(0, 180, 0);
        }
        while (isGoingToHive)
        {
            if (dist > 0f)
            {
                moveStep           = MoveDir * (speed * 0.02f /*Time.deltaTime */);      //replaced 0.03f with Time.deltaTime. I'll explain it in detail if you don't know why 0.03f will not work
                dist              -= moveStep.magnitude;
                QBParent.position += moveStep;
            }
            else
            {
                isGoingToHive = false;
            }
            yield return(new WaitForSeconds(0.03f));
        }
        BeeM.HiveShake(value);
        Kill();
    }
Пример #2
0
 public override void Kill()
 {
     BeeM.RemoveBee(gameObject);
     Destroy(QBParent.gameObject);
 }