Exemple #1
0
 void SetBehaviorOutside()
 {
     if (isForceState)
     {
         return;               //若是強制執行狀態如攻擊,直接return
     }
     //丟香蕉基本秒數為三秒丟一次
     if (bananaTime < 3.0f)
     {
         bananaTime += Time.deltaTime;
         if (inState_time >= state_time && state_time > 0.1f) //每個狀態的時間到換新的,為了不蓋過
         {
             SetState(-1, false);                             //到新狀態,狀態時間加一個判斷大於0.1
         }
     }
     else
     {
         if (inState_time >= state_time)
         {
             //可丟香蕉數大於0且七成機率丟出香蕉
             if (childProjectSystem.GetFreeNum() > 0 && Random.Range(0.0f, 1.0f) > 0.7f)
             {
                 SetState(2, true);
             }
             bananaTime = 0.0f;
         }
     }
     //new_pos = transform.position + new Vector3(0, f_pos_offsetY, 0); //更新新的位置座標
 }
 void SetBehaviorOutside()
 {
     if (isForceState)
     {
         return;               //若是強制執行狀態如攻擊,直接return
     }
     if (webTime < 3.0f)
     {
         webTime += Time.deltaTime;
         if (inState_time >= state_time && state_time > 0.1f) //每個狀態的時間到換新的,為了不蓋過
         {
             SetState(-1, false);                             //到新狀態,狀態時間加一個判斷大於0.1
         }
     }
     else
     {
         if (inState_time >= state_time)
         {
             Vector2   selfPos2d = new Vector2(new_pos.x, new_pos.y);
             LayerMask webLayer  = 1 << LayerMask.NameToLayer("Obstacle") | 1 << LayerMask.NameToLayer("ObstacleForOut") |
                                  1 << LayerMask.NameToLayer("DamageToPlayer");
             Collider2D detectWeb = Physics2D.OverlapCircle(selfPos2d, 0.3f, webLayer);
             if (detectWeb == null)
             {
                 if (childProjectSystem.GetFreeNum() > 0 && Random.Range(0.0f, 1.0f) > 0.7f)
                 {
                     SetState(2, true);
                 }
             }
             webTime = 0.0f;
         }
     }
     //new_pos = transform.position + new Vector3(0, f_pos_offsetY, 0); //更新新的位置座標
 }
Exemple #3
0
    public void OnBuildingTrape()
    {
        if (childProjectSystem.GetFreeNum() <= 0)
        {
            return;
        }
        Vector3 pos = new Vector3(transform.position.x, transform.position.y - 0.6f, transform.position.z);

        childProjectSystem.AddUsed(pos);
        childProjectSystem.GetNewestChild().SetOn(false, fakeCallBack);
    }