Пример #1
0
 public void Execute()
 {
     Patrol();
     boss.Move();
     if (boss.Target != null)
     {
         boss.ChangeState(new RangeState());
     }
 }
Пример #2
0
 public void Execute()
 {
     if (boss.Target != null)
     {
         boss.Move();
         ThrowKnife();
     }
     else
     {
         boss.ChangeState(new IdleState());
     }
 }
Пример #3
0
    void FixedUpdate()
    {
        // process message queue
        foreach (Message m in msgList)
        {
            switch (m.Type)
            {
            case "PlayerJoined":
                if (GameObject.Find(m.GetString(0)))
                {
                    Destroy(GameObject.Find(m.GetString(0)));
                }

                GameObject newplayer = GameObject.Instantiate(PlayerPrefab) as GameObject;
                newplayer.transform.position = new Vector3(m.GetFloat(1), m.GetFloat(2), m.GetFloat(3));

                Debug.Log(m.ToString());
                newplayer.name = m.GetString(0);

                newplayer.transform.Find("NameTag").GetComponent <TextMesh> ().text = m.GetString(0);
                newplayer.GetComponent <AnimationSkinManager> ().CreateSkin(skinList [Mathf.RoundToInt(m.GetFloat(5))]);
                //pioconnection.Send("Skin",PlayerPrefs.GetInt("Skin"));
                newplayer.transform.rotation = Quaternion.Euler(new Vector3(0, m.GetFloat(4), 0));
                playerInGame.Add(newplayer);
                break;

            case "PlayerLeft":
                Destroy(playerInGame.Find(obj => obj.name == m.GetString(0)));
                playerInGame.RemoveAt(playerInGame.FindIndex(obj => obj.name == m.GetString(0)));
                portal.SetActive(true);
                Debug.Log("PlayerLeft : " + m.GetString(0));


                break;

            case "Move":
                if (userid != m.GetString(0))
                {
                    if (playerInGame.Find(obj => obj.name == m.GetString(0)) != null)
                    {
                        GameObject upplayer = playerInGame.Find(obj => obj.name == m.GetString(0));
                        //Debug.Log (m);
                        var control = upplayer.GetComponent <PlayerMoveControll> ();
                        control.newPos = new Vector3(m.GetFloat(1), m.GetFloat(2), m.GetFloat(3));
                        control.start  = true;
                        control.roty   = m.GetFloat(4);
                        upplayer.GetComponent <AnimationSkinManager> ().MoveAnimation();
                    }
                }
                break;

            case "MoveBoss":


                bossManager.Move(m.GetFloat(0), m.GetFloat(1));
                break;

            case "Rotation":

                if (userid != m.GetString(0))
                {
                    GameObject upplayer2 = GameObject.Find(m.GetString(0));
                    // remove the object when it's picked up
                    var control = upplayer2.GetComponent <PlayerMoveControll>();
                    control.roty = m.GetFloat(1);
                }
                break;

            case "Fire":



                hpslider.value = m.GetInt(1);

                //pl2.BloodUp ();
                //pl.GetComponent<AnimationSkinManager> ().DamageAnimation();

                Debug.Log("bloood");



                break;

            case "Start":



                //pl2.BloodUp ();
                //pl.GetComponent<AnimationSkinManager> ().DamageAnimation();

                Debug.Log("StartBoss");



                break;

            case "GetDamage":



                if (playerInGame.Find(obj => obj.name == m.GetString(0)) != null)
                {
                    playerInGame.Find(obj => obj.name == m.GetString(0)).GetComponent <PlayerInfo> ().GetDamage(m.GetInt(1));
                }



                break;

            case "FireBall":

                Vector3 posBall = new Vector3(m.GetFloat(0), m.GetFloat(1), m.GetFloat(2));
                if (m.GetString(6) == target.name)
                {
                    var rotate = Quaternion.Euler(new Vector3(m.GetFloat(3), m.GetFloat(4), m.GetFloat(5)));
                    Instantiate(fireball, posBall, rotate);
                }
                else
                {
                    if (playerInGame.Find(obj => obj.name == m.GetString(6)) != null)
                    {
                        playerInGame.Find(obj => obj.name == m.GetString(6)).GetComponent <AnimationSkinManager>
                            ().AttackAnimation();
                    }
                }



                break;


            case "Round":
                round.SetActive(true);
                StartCoroutine(CloseObject(round));
                Debug.Log("My team: " + m.GetInt(0));
                statusGame = true;
                team       = m.GetInt(0);

                if (team == 1)
                {
                    var rezone = ZoneRedSpawn.transform.localScale;
                    target.transform.position = ZoneRedSpawn.transform.position + new Vector3(Random.Range(-rezone.z / 2, rezone.z / 2),
                                                                                              Random.Range(-rezone.y / 2, rezone.y / 2)
                                                                                              , Random.Range(-rezone.x / 2, rezone.x / 2));
                }
                if (team == 2)
                {
                    var rezone = ZoneBlueSpawn.transform.localScale;
                    target.transform.position = ZoneBlueSpawn.transform.position + new Vector3(Random.Range(-rezone.z / 2, rezone.z / 2),
                                                                                               Random.Range(-rezone.y / 2, rezone.y / 2)
                                                                                               , Random.Range(-rezone.x / 2, rezone.x / 2));
                }
                pioconnection.Send("Move", target.transform.position.x, target.transform.position.y, target.transform.position.z, target.transform.rotation.eulerAngles.y);


                //GameObject upplayer4 = GameObject.Find(m.GetString(0));

                break;

            case "EndGame":
                portal.SetActive(true);


                winGame.SetActive(true);
                StartCoroutine(CloseObject(winGame));
                bossAnimatorl.SetBool("die", true);
                boxcolBoss.enabled = false;

                Debug.Log("Player win:");
                //GameObject upplayer4 = GameObject.Find(m.GetString(0));

                break;
            }
        }

        msgList.Clear();
    }