コード例 #1
0
    public void ShootEgg(int[] index, bool randDir = false)
    {
        for (int i = 0; i < index.Length; i++)
        {
            Bullet     b    = BulletManager.Instance().AddBullet(BulletManager.BULLET_TYPE.EGG_BULLET);
            GameObject bone = m_boneList[index[i]];

            Vector3 dir = m_target.transform.position - bone.transform.position;
            dir.Normalize();

            if (randDir)
            {
                float t = (UnityEngine.Random.Range(0, 2) == 1) ? 1.0f : -1.0f;
                dir *= t;

                dir = new Vector3(dir.x + UnityEngine.Random.Range(-0.3f, 0.3f), dir.y + UnityEngine.Random.Range(-0.3f, 0.3f));
            }

            string name = GameManager.Instance().PLAYER.USER_NAME + "_boss2_" + Monster.m_index++;
            b.SetupBullet(name, false, dir);
            b.BULLET_SPEED = 20.0f + UnityEngine.Random.Range(-10.0f, 10.0f);
            Vector3 pos = bone.transform.position;
            b.transform.position = pos;

            NetworkManager.Instance().SendOrderMessage(
                JSONMessageTool.ToJsonCreateOrder(
                    name,
                    "boss1_bullet",
                    pos.x, pos.y,
                    b.transform.rotation.eulerAngles.y,
                    false));
        }
    }
コード例 #2
0
    void Update()
    {
        //MDebug.Log("BULLET");
        float angle = 0.0f;

        if (Input.GetKey(KeyCode.U))
        {
            angle = -0.5f;
            transform.Rotate(new Vector3(0, 0, angle), Space.World);
        }

        if (Input.GetKey(KeyCode.J))
        {
            angle = 0.5f;
            transform.Rotate(new Vector3(0, 0, angle), Space.World);
        }

        if (Input.GetKeyUp(KeyCode.Space))
        {
            Bullet  b   = BulletManager.Instance().AddBullet(BulletManager.BULLET_TYPE.B_HERO_DEF);
            Vector3 pos = transform.position;
            //float width = (m_renderer.flipX) ? m_renderer.bounds.size.x / 2.0f : -m_renderer.bounds.size.x / 2.0f;
            b.transform.position = new Vector3(pos.x, pos.y, pos.z);

            b.transform.rotation = transform.rotation;

            string n = GameManager.Instance().PLAYER.USER_NAME + "_" + index;
            b.SetupBullet(n, false, Vector3.zero);
            //MDebug.Log("b " + n + "     " + JSONMessageTool.ToJsonCreateOrder(n, "myTeam_bullet", pos.x, pos.y, pos.z, bullet.GetComponent<SpriteRenderer>().flipX));
            NetworkManager.Instance().SendOrderMessage(JSONMessageTool.ToJsonCreateOrder(n, "myTeam_bullet", pos.x, pos.y, pos.z, b.GetComponent <SpriteRenderer>().flipX));
            index++;
        }
    }
コード例 #3
0
    // -- 적 생성 ----------------------------------------------------------------------------------------------- //


    public GameObject AddMonster(string prefabPath, string name, Vector3 pos)
    {
        GameObject monster = AddObject(prefabPath, pos);

        if (monster != null)
        {
            if (prefabPath.Equals(GamePath.BOSS1))
            {
                monster.GetComponent <Stage1BOSS>().MONSTER_NAME = name;

                NetworkManager.Instance().SendOrderMessage(JSONMessageTool.ToJsonCreateOrder(name, "boss1", pos.x, pos.y, pos.z));
            }
            else if (prefabPath.Equals(GamePath.BOSS2))
            {
                monster.GetComponent <Stage2Boss>().MONSTER_NAME = name;

                NetworkManager.Instance().SendOrderMessage(JSONMessageTool.ToJsonCreateOrder(name, "boss2", pos.x, pos.y, pos.z));
            }
            else if (prefabPath.Equals(GamePath.MONSTER1))
            {
                monster.GetComponent <Stage1Monster>().MONSTER_NAME = name;
                NetworkManager.Instance().SendOrderMessage(JSONMessageTool.ToJsonCreateOrder(name, "monster1"));
            }
            else if (prefabPath.Equals(GamePath.MONSTER2))
            {
                monster.GetComponent <Stage1Monster>().MONSTER_NAME = name;
                NetworkManager.Instance().SendOrderMessage(JSONMessageTool.ToJsonCreateOrder(name, "monster2"));
            }
            else if (prefabPath.Equals(GamePath.INSIDE_MONSTER))
            {
                monster.GetComponent <InsidePentrationMonster>().MONSTER_NAME = name;
            }
        }
        return(monster);
    }
コード例 #4
0
    void Start()
    {
        m_source = this.GetComponent <AudioSource>();
        if (m_network == false)
        {
            return;
        }
        Vector2 p = transform.position;

        NetworkManager.Instance().SendOrderMessage(
            JSONMessageTool.ToJsonCreateOrder(
                "eff_" + GameManager.Instance().PLAYER.USER_NAME + "_" + this.GetHashCode(),
                "effect",
                p.x, p.y, -1.0f));
    }
コード例 #5
0
    bool NetworkObjectCheck()
    {
        if (m_isNetworkObject)
        {
            return(false);
        }

        if (m_networkObjectCheck)
        {
            return(true);
        }
        if (GameManager.Instance().m_curSceneState.Equals("play") &&
            NetworkOrderController.ORDER_NAME.Equals(GameManager.Instance().PLAYER.USER_NAME))
        {
            Vector3 pos = transform.position;
            m_name = "monster_" + GameManager.Instance().PLAYER.USER_NAME + "_" + this.GetHashCode();
            string dataName = m_skeletonAnimation.skeletonDataAsset.name;

            if (dataName.Equals("mon_planet2_SkeletonData"))
            {
                // 수정해라
                NetworkManager.Instance().SendOrderMessage(
                    JSONMessageTool.ToJsonCreateOrder(m_name, "PlanetMonster2", pos.x, pos.y, -1.0f));
            }


            NetworkManager.Instance().SendOrderMessage(JSONMessageTool.ToJsonOrderStateValueChange(m_name, m_hp));
            MoveSend();

            NetworkManager.Instance().AddNetworkOrderMessageEventListener(this);
            m_networkObjectCheck = true;

            // 초기 시작값
            this.m_skeletonAnimation.state.SetAnimation(0, ANI_IDLE, true);
            // m_heroTarget = GameManager.Instance().PLAYER.PLAYER_HERO;
            return(true);
        }
        else if (!string.IsNullOrEmpty(NetworkOrderController.ORDER_NAME) && !string.IsNullOrEmpty(GameManager.Instance().PLAYER.USER_NAME) &&
                 !NetworkOrderController.ORDER_NAME.Equals(GameManager.Instance().PLAYER.USER_NAME))
        {
            GameObject.Destroy(gameObject);
        }
        return(false);
    }
コード例 #6
0
    private void State_Complete(Spine.TrackEntry trackEntry)
    {
        if (trackEntry.animation.name.Equals(m_attackAni))
        {
            if (m_tick >= GameSetting.BOSS1_PATTERN_A_ATTACK_COOLTIME)
            {
                Bullet  b   = BulletManager.Instance().AddBullet(BulletManager.BULLET_TYPE.B_BOSS1_P1);
                Vector3 pos = m_monster.transform.position;

                b.transform.position = pos;

                Vector3 dir = m_hero.transform.position - m_monster.transform.position;
                dir.Normalize();
                string name = GameManager.Instance().PLAYER.USER_NAME + "_boss_A_" + Monster.m_index++;

                b.BULLET_SPEED       = 20.0f;
                b.transform.position = m_monster.transform.position;
                b.SetupBullet(name, false, dir);

                NetworkManager.Instance().SendOrderMessage(
                    JSONMessageTool.ToJsonCreateOrder(
                        name,
                        "boss1_bullet",
                        pos.x, pos.y,
                        b.transform.rotation.eulerAngles.y,
                        false));
                // 총알은 2.5초에 걸쳐 플레이어에게 도착함
                // 총알의 계산은 총알에서 하도록 함
                m_tick = 0.0f;

                //m_monster.GetComponent<Stage1BOSS>().m_attackEffect.Play("boss_shotEffect");

                NetworkManager.Instance().SendOrderMessage(
                    JSONMessageTool.ToJsonAIMessage(
                        m_aiTarget,
                        "A",
                        m_moveAni,
                        true));
                m_skletonAnimation.state.SetAnimation(0, m_moveAni, true);
            }
        }
    }
コード例 #7
0
    void FireBullet()
    {
        bool   flip = m_skletonAnimation.skeleton.flipX;
        Bullet b    = BulletManager.Instance().AddBullet(BulletManager.BULLET_TYPE.B_HERO_DEF);

        Vector3 pos = m_gunBone.transform.position;

        b.transform.rotation = Quaternion.Euler(0.0f, 0.0f, m_gunBone.transform.rotation.eulerAngles.z - 90.0f);

        b.transform.position = pos;


        // 네트워크 식별 이름
        string n = GameManager.Instance().PLAYER.USER_NAME + "_" + m_bulletIndex;

        b.SetupBullet(n, false, Vector3.zero, 0.0f, m_skletonAnimation.skeleton.flipX);

        NetworkManager.Instance().SendOrderMessage(JSONMessageTool.ToJsonCreateOrder(n, "myTeam_bullet", pos.x, pos.y, pos.z, flip));
        m_bulletIndex++;
    }
コード例 #8
0
    public void PentrationMonsterCreate()
    {
        int     r   = Random.Range(0, 2);
        Vector3 pos = Vector3.zero;

        if (r == 0)
        {
            pos = m_robo_in_monsterPos1.transform.position;
        }
        else
        {
            pos = m_robo_in_monsterPos2.transform.position;
        }

        string name = "monster_" + GameManager.Instance().PLAYER.USER_NAME + "_inside_" + m_roboInMonsterIndex;

        NetworkManager.Instance().SendOrderMessage(
            JSONMessageTool.ToJsonCreateOrder(
                name, "InsidePentrationMonster", pos.x, pos.y, -1.0f));
        AddMonster(GamePath.INSIDE_MONSTER, name, pos);
        m_roboInMonsterIndex++;
    }
コード例 #9
0
    bool NetworkObjectCheck()
    {
        if (m_isNetworkObject)
        {
            return(false);
        }

        if (m_networkObjectCheck)
        {
            return(true);
        }
        if (GameManager.Instance().m_curSceneState.Equals("play") &&
            NetworkOrderController.ORDER_NAME.Equals(GameManager.Instance().PLAYER.USER_NAME))
        {
            Vector3 pos = transform.position;
            m_name = "monster_" + GameManager.Instance().PLAYER.USER_NAME + "_" + this.GetHashCode();
            string dataName = m_skeletonAnimation.skeletonDataAsset.name;

            NetworkManager.Instance().SendOrderMessage(
                JSONMessageTool.ToJsonCreateOrder(m_name, "InsidePentrationMonster", pos.x, pos.y, -1.0f));


            NetworkManager.Instance().SendOrderMessage(JSONMessageTool.ToJsonOrderStateValueChange(m_name, m_hp));
            MoveSend();

            NetworkManager.Instance().AddNetworkOrderMessageEventListener(this);
            m_networkObjectCheck = true;
            m_skeletonAnimation.state.Complete += State_Complete;
            return(true);
        }
        else if (!string.IsNullOrEmpty(NetworkOrderController.ORDER_NAME) && !string.IsNullOrEmpty(GameManager.Instance().PLAYER.USER_NAME) &&
                 !NetworkOrderController.ORDER_NAME.Equals(GameManager.Instance().PLAYER.USER_NAME))
        {
            GameObject.Destroy(gameObject);
        }
        return(false);
    }
コード例 #10
0
    bool NetworkObjectCheck()
    {
        if (m_tutorial)
        {
            if (m_pattern == null)
            {
                m_pattern = new MonsterPattern(m_skeletonAnimation, ANI_MOVE, ANI_ATTACK, null);
                m_skeletonAnimation.state.Complete += State_Complete;
            }
            return(true);
        }
        if (m_isNetworkObject)
        {
            return(false);
        }

        if (m_networkObjectCheck)
        {
            return(true);
        }
        if (GameManager.Instance().m_curSceneState.Equals("play") &&
            NetworkOrderController.ORDER_NAME.Equals(GameManager.Instance().PLAYER.USER_NAME))
        {
            Vector3 pos = transform.position;
            m_name = "monster_" + GameManager.Instance().PLAYER.USER_NAME + "_" + this.GetHashCode();
            string dataName = m_skeletonAnimation.skeletonDataAsset.name;

            if (dataName.Equals("mon2_SkeletonData"))
            {
                NetworkManager.Instance().SendOrderMessage(
                    JSONMessageTool.ToJsonCreateOrder(m_name, "monster1", pos.x, pos.y, -1.0f));
            }
            else if (dataName.Equals("mon3_SkeletonData"))
            {
                NetworkManager.Instance().SendOrderMessage(
                    JSONMessageTool.ToJsonCreateOrder(m_name, "monster2", pos.x, pos.y, -1.0f));
            }
            else if (dataName.Equals("mon_space1_SkeletonData"))
            {
                NetworkManager.Instance().SendOrderMessage(
                    JSONMessageTool.ToJsonCreateOrder(m_name, "SpaceMonster1", pos.x, pos.y, -1.0f));
            }
            else if (dataName.Equals("mon_space2_SkeletonData"))
            {
                NetworkManager.Instance().SendOrderMessage(
                    JSONMessageTool.ToJsonCreateOrder(m_name, "SpaceMonster2", pos.x, pos.y, -1.0f));
            }
            ///행성 몹
            else if (dataName.Equals("mon_planet1_SkeletonData"))
            {
                NetworkManager.Instance().SendOrderMessage(
                    JSONMessageTool.ToJsonCreateOrder(m_name, "PlanetMonster1", pos.x, pos.y, -1.0f));
                m_curAttackType = AttackType.MOVE_AND_ATTACK;
            }
            else if (dataName.Equals("mon_planet3_SkeletonData"))
            {
                NetworkManager.Instance().SendOrderMessage(
                    JSONMessageTool.ToJsonCreateOrder(m_name, "PlanetMonster3", pos.x, pos.y, -1.0f));
                m_curAttackType = AttackType.MOVE_AND_ATTACK;
            }

            NetworkManager.Instance().SendOrderMessage(JSONMessageTool.ToJsonOrderStateValueChange(m_name, m_hp));
            MoveSend();

            NetworkManager.Instance().AddNetworkOrderMessageEventListener(this);
            m_networkObjectCheck = true;
            m_pattern            = new MonsterPattern(m_skeletonAnimation, ANI_MOVE, ANI_ATTACK, m_name);
            m_skeletonAnimation.state.Complete += State_Complete;
            return(true);
        }
        else if (!string.IsNullOrEmpty(NetworkOrderController.ORDER_NAME) && !string.IsNullOrEmpty(GameManager.Instance().PLAYER.USER_NAME) &&
                 !NetworkOrderController.ORDER_NAME.Equals(GameManager.Instance().PLAYER.USER_NAME))
        {
            GameObject.Destroy(gameObject);
        }
        return(false);
    }