コード例 #1
0
    // 移动
    private void Moving()
    {
        if (moving)
        {
            if (player != null)
            {
                float x = -movintSpeed *Mathf.Sin(orientAngle),
                      y = movintSpeed * Mathf.Cos(orientAngle);

                // 动画、行走 方向相反
                if ((x < 0 && !orientLeft) || (x > 0 && orientLeft))
                {
                    Vector3 playerScale = player.transform.localScale;
                    player.transform.localScale = new Vector3(-playerScale.x, playerScale.y, playerScale.z);

                    orientLeft = x < 0 ? true : false;
                }

                player.GetComponent <Rigidbody>().velocity = new Vector3(x, 0.1f, y);
            }
            GameRoot_InBattle.getSingleton <MessageManager_InBattle>().SendMessage_PlayerMoveEvent(player.transform.position);
        }
        else
        {
            player.GetComponent <Rigidbody>().velocity = Vector3.zero;
        }
    }
コード例 #2
0
    /// <summary>
    /// 读取某关卡的怪物信息数据
    /// </summary>
    /// <param name="path"></param>
    /// <returns></returns>
    public List <Monster> loadMonterDataForStage(string path)
    {
        List <Monster> list = PlayerManager.instance.xmlToObject <List <Monster> >(path);

        monstersDependOnPosition = new List <Monster>();

        //StartCoroutine(WaitForCreateMonster(list[0]));
        foreach (Monster monster in list)
        {
            if (monster.DependOnTime)
            {
                StartCoroutine(WaitForCreateMonster(monster));
            }
            else if (monster.DependOnPosition)
            {
                monstersDependOnPosition.Add(monster);
            }
        }
        if (monstersDependOnPosition.Count > 0)
        {
            GameRoot_InBattle.getSingleton <MessageManager_InBattle>().playerMoveEvent
                += new MessageManager_InBattle.PlayerMoveDelegrate(checkPlayerPositionForMonsterCreate);
        }

        return(list);
    }
コード例 #3
0
ファイル: ShotItem.cs プロジェクト: z395802609/BengHuai2
    public void OnPress(bool press)
    {
        if (press)
        {
            pressed = true;
            //print("Press");

            if (!CDOver)
            {
                return;
            }

            if (hasShoot && !weapon.ContinueShoot)
            {
                return;
            }

            gameObject.GetComponent <UISprite>().spriteName = "WeaponContainer_2";
            shoot();
        }
        else
        {
            pressed = false;
            //print("UnPress");

            hasShoot = false;

            gameObject.GetComponent <UISprite>().spriteName = "WeaponContainer_1";
            GameRoot_InBattle.getSingleton <MessageManager_InBattle>().SendMessage_ShotItemReleaseEvent(index, weapon);
        }
    }
コード例 #4
0
ファイル: Bullets.cs プロジェクト: z395802609/BengHuai2
 public void OnTriggerEnter(Collider collider)
 {
     //Debug.Log("Bullet OnTriggerEnter");
     if ((sender == Sender.Player || collider.tag == "Player") && (gameObject.tag != collider.tag))
     {
         GameRoot_InBattle.getSingleton <MessageManager_InBattle>().SendMessage_BulletCollisionEvent(this, collider.gameObject, collider.GetComponent <CharacterData>());
     }
 }
コード例 #5
0
    // 反注册事件
    private void UnRegisterEvent()
    {
        GameRoot_InBattle.getSingleton <MessageManager_InBattle>().rockerEvent
            -= new MessageManager_InBattle.RockedDelegrate(RockerEvent);

        GameRoot_InBattle.getSingleton <MessageManager_InBattle>().shotItemPressEvent
            -= new MessageManager_InBattle.ShotItemDelegrate(PressWeapon);
    }
コード例 #6
0
ファイル: ShotItem.cs プロジェクト: z395802609/BengHuai2
    // Use this for initialization
    void Start()
    {
        pressed  = false;
        CDOver   = true;
        hasShoot = false;

        GameRoot_InBattle.getSingleton <MessageManager_InBattle>().shotSuccessfulEvent
            += new MessageManager_InBattle.ShotItemDelegrate(ShotSuccessful);
    }
コード例 #7
0
    /// <summary>
    /// (被打者)处理子弹伤害
    /// </summary>
    /// <param name="bullet"></param>
    /// <param name="monster"></param>
    /// <param name="charaterData"></param>
    private void DealWithHurt(Bullets bullet, GameObject monster, CharacterData charaterData)
    {
        float hurt = bullet.weapon.Attack;

        //Debug.Log(monster.name);
        //Debug.Log(monster.GetComponent<HP_Text_Manager>() == null);
        GameRoot_InBattle.getSingleton <MessageManager_InBattle>().SendMessage_MonsterHurtEvent(bullet, monster, charaterData, hurt);
        charaterData.HP_Current -= hurt;
        //monster.GetComponent<HP_Text_Manager>().showHurt((int)hurt);
    }
コード例 #8
0
    // Use this for initialization
    void Start()
    {
        player = GameRoot_InBattle.getSingleton <PlayerManager_InBattle>().player.GetComponent <Player>();
        if (player != null)
        {
            moveToPlayer(player.transform.position);
        }

        registerEvent();
        closePlayer = false;
    }
コード例 #9
0
    /// <summary>
    /// 在场上创建怪物
    /// </summary>
    /// <param name="monster"></param>
    private void createMonsterOnScene(Monster monster)
    {
        GameObject monsterGO = Pool.Instance.getObjFromPool(Pool.PoolType.Monster);
        float      x         = monster.Position.x,
                   z = monster.Position.z;

        z = z > 6.4 ? 6.4f : z;
        z = z < -3 ? -3f : z;
        monsterGO.transform.position = new Vector3(x, 4.3f, z);
        monsterGO.SendMessage("SetMonster", monster);
        monsterGO.SetActive(true);
        monsterGO.AddComponent <AI_1>();

        CharacterData data = monsterGO.GetComponent <CharacterData>();

        data.monster    = monster;
        data.HP_Current = monster.Hp;
        data.ID         = ++monsterIndex;

        GameRoot_InBattle.getSingleton <MessageManager_InBattle>().SendMessage_CreateMonsterEvent(monsterGO, monster, data);
    }
コード例 #10
0
    // 按下“开枪”按键事件
    private void PressWeapon(int index, Weapon weapon)
    {
        //Debug.Log("Shot");
        if (weapon == null)
        {
            return;
        }

        GameObject bulletGO = Pool.Instance.getObjFromPool(Pool.PoolType.Bullet);
        Bullets    bullet   = bulletGO.GetComponent <Bullets>();

        // 设置子弹与武器相关的属性
        switch (weapon.Type)
        {
        case EquipmentManager.WeaponType.Rifle:
            //bullet.bulletGameObject.GetComponent<MeshRenderer>().material.mainTexture = Resources.Load("Effect/Ammo_001_mip_1") as Texture;
            // 发射者
            bullet.sender = Bullets.Sender.Player;
            // 位置
            bulletGO.transform.position = player.transform.FindChild("Point_Rifle").position;
            // 方向
            bulletGO.transform.rotation = new Quaternion(0, 0, orientLeft ? 0 : 180, 0);
            //bullet.bulletGameObject.transform.LookAt(orientLeft ? GameRoot_InBattle.getSingleton<BulletsManager>().go_Left.transform.position
            //    : GameRoot_InBattle.getSingleton<BulletsManager>().go_Right.transform.position);
            // 速度
            bulletGO.GetComponent <Rigidbody>().velocity = new Vector3(weapon.BulletSpeed * (orientLeft ? -1 : 1),
                                                                       0, Random.Range(-weapon.BulletAngle, weapon.BulletAngle));
            // 自动销毁协程
            StartCoroutine(DestroyBulletCoroutine(3, bullet));

            break;
        }
        // 子弹图片
        bulletGO.GetComponent <MeshRenderer>().material = Resources.Load(weapon.BulletPath) as Material;

        bullet.weapon = weapon;
        // 发送“子弹发射成功”消息
        GameRoot_InBattle.getSingleton <MessageManager_InBattle>().SendMessage_ShotSuccessfulEvent(index, weapon);
    }
コード例 #11
0
    /// <summary>
    /// 玩家移动了,检查是否到了怪应该出现的位置
    /// </summary>
    /// <param name="position"></param>
    private void checkPlayerPositionForMonsterCreate(Vector3 position)
    {
        //Debug.Log("Check Position  " + position.x + "   " + monstersDependOnPosition[0].PlayerArrive);

        int     index = 0;
        Monster monster;

        while (index < monstersDependOnPosition.Count)
        {
            monster = monstersDependOnPosition[index++];
            if (position.x > monster.PlayerArrive)
            {
                Debug.Log("Create DependOn Postion");
                createMonsterOnScene(monster);
                monstersDependOnPosition.Remove(monster);
            }
        }
        if (monstersDependOnPosition.Count == 0)
        {
            GameRoot_InBattle.getSingleton <MessageManager_InBattle>().playerMoveEvent
                -= new MessageManager_InBattle.PlayerMoveDelegrate(checkPlayerPositionForMonsterCreate);
        }
    }
コード例 #12
0
 private void UnRegisterEvent()
 {
     GameRoot_InBattle.getSingleton <MessageManager_InBattle>().playerMoveEvent
         -= new MessageManager_InBattle.PlayerMoveDelegrate(moveToPlayer);
 }
コード例 #13
0
 private void UnRegierterEvent()
 {
     GameRoot_InBattle.getSingleton <MessageManager_InBattle>().bulletCollisionEvent
         -= new MessageManager_InBattle.BulletCollisionDelegrate(BulletCollision);
 }
コード例 #14
0
 void OnDestroy()
 {
     GameRoot_InBattle.getSingleton <MessageManager_InBattle>().playerMoveEvent
         -= new MessageManager_InBattle.PlayerMoveDelegrate(checkPlayerPositionForMonsterCreate);
 }
コード例 #15
0
 // Use this for initialization
 void Start()
 {
     GameRoot_InBattle.getSingleton <Mapcreater_2>().createMap(30);
     Pool.Instance.createObjPool(Resources.Load("Prefabs/InBattle/Bullet") as GameObject, Pool.PoolType.Bullet, 20);
 }
コード例 #16
0
ファイル: RockerManager.cs プロジェクト: z395802609/BengHuai2
 // 松开摇杆
 private void ReleaseRocker()
 {
     //Debug.Log("ReleaseRocker");
     setImageSelected(false);
     GameRoot_InBattle.getSingleton <MessageManager_InBattle>().SendMessage_RockedEvent(angle, false);
 }
コード例 #17
0
ファイル: ShotItem.cs プロジェクト: z395802609/BengHuai2
 void OnDestroy()
 {
     GameRoot_InBattle.getSingleton <MessageManager_InBattle>().shotSuccessfulEvent
         -= new MessageManager_InBattle.ShotItemDelegrate(ShotSuccessful);
 }
コード例 #18
0
ファイル: ShotItem.cs プロジェクト: z395802609/BengHuai2
 // 开枪
 private void shoot()
 {
     GameRoot_InBattle.getSingleton <MessageManager_InBattle>().SendMessage_ShotItemPressEvent(index, weapon);
 }
コード例 #19
0
ファイル: HP_Slider.cs プロジェクト: z395802609/BengHuai2
 void OnDestroy()
 {
     GameRoot_InBattle.getSingleton <MessageManager_InBattle>().monsterHurtEvent
         -= new MessageManager_InBattle.MonsterHurtDelegrate(MonsterHurted);
 }
コード例 #20
0
ファイル: HP_Slider.cs プロジェクト: z395802609/BengHuai2
 // Use this for initialization
 void Start()
 {
     GameRoot_InBattle.getSingleton <MessageManager_InBattle>().monsterHurtEvent
         += new MessageManager_InBattle.MonsterHurtDelegrate(MonsterHurted);
 }
コード例 #21
0
 private void UnRegisterEvent()
 {
     GameRoot_InBattle.getSingleton <MessageManager_InBattle>().createMonsterEvent
         -= new MessageManager_InBattle.CreateMonsterDelegrate(createMonsterEvent);
 }
コード例 #22
0
ファイル: RockerManager.cs プロジェクト: z395802609/BengHuai2
 // 移动摇杆
 private void MoveRocker()
 {
     setImageSelected(true);
     RotateImage(Input.mousePosition.x - centerX, Input.mousePosition.y - centerY);
     GameRoot_InBattle.getSingleton <MessageManager_InBattle>().SendMessage_RockedEvent(angle, true);
 }