Ejemplo n.º 1
0
    public void OnSwapGunModel()
    {
        _eESwapGunState = ESwapGunState.UP;
        //换枪
        baseActor.info.useGunIndex++;
        if (baseActor.info.useGunIndex > baseActor.info.m_GunList.Count - 1)
            baseActor.info.useGunIndex = 0;

        int index = baseActor.info.useGunIndex - 1;
        if (index < 0) index = baseActor.info.m_GunList.Count - 1;
        baseActor.info.m_GunList[index].info.obj.SetActive(false);
        baseActor.info.m_GunList[baseActor.info.useGunIndex].info.obj.SetActive(true);

        //瞄准镜
        if (baseActor.info.m_GunList[baseActor.info.useGunIndex].info.aim_scale < 0.1f)
            Global.Instance.battle.BattleUI.GetComponent<BattleUI>().Aim.gameObject.SetActive(false);
        else
            Global.Instance.battle.BattleUI.GetComponent<BattleUI>().Aim.gameObject.SetActive(true);

        if (Global.Instance.battle.BattleUI.GetComponent<BattleUI>().AimBack.gameObject.activeSelf)
            Global.Instance.battle.BattleUI.GetComponent<BattleUI>().OnCameraField();

        //弹药
        Global.Instance.battle.BattleUI.GetComponent<BattleUI>().BulletCount.text = baseActor.info.m_GunList[baseActor.info.useGunIndex].info.curCount.ToString();
        //频率
        if (baseActor.info.m_GunList[baseActor.info.useGunIndex].info.frequency == 0)
            Global.Instance.battle.BattleUI.GetComponent<BattleUI>().Center.GetComponent<Button_Center>().fireControl.delta = 10000;
        else
            Global.Instance.battle.BattleUI.GetComponent<BattleUI>().Center.GetComponent<Button_Center>().fireControl.delta = 1.0f / baseActor.info.m_GunList[baseActor.info.useGunIndex].info.frequency;

        //枪图标
        Global.Instance.battle.BattleUI.GetComponent<BattleUI>().GunIcon.spriteName = Enum.GetName(typeof(Gun.Num), baseActor.info.m_GunList[baseActor.info.useGunIndex].info.num);

        Global.Instance.battle.BattleUI.GetComponent<BattleUI>().GunIcon.SetDimensions(
            Global.Instance.battle.BattleUI.GetComponent<BattleUI>().GunIcon.GetAtlasSprite().width,
            Global.Instance.battle.BattleUI.GetComponent<BattleUI>().GunIcon.GetAtlasSprite().height);

        //逆向
        //TweenRotation tweenRotation = baseActor.info.swapGunPoint.GetComponent<TweenRotation>();
        //tweenRotation.SetOnFinished(OnSwapGunComplete);
        //tweenRotation.from = new Vector3(30.0f, 0.0f, 0.0f);
        //tweenRotation.to = new Vector3(0.0f, 0.0f, 0.0f);
        //tweenRotation.duration = 0.55f;
        //tweenRotation.style = UITweener.Style.Once;        

        ////tweenRotation.ResetToBeginning();
        //tweenRotation.PlayReverse();

        iTween.StopByName(baseActor.info.m_GunList[baseActor.info.useGunIndex].info.obj, "Swap_gun_down");
        Hashtable hashtable = new Hashtable();
        hashtable.Add("name", "Swap_gun_up");
        hashtable.Add("time", 0.275f);
        hashtable.Add("x", 0.0f);
        hashtable.Add("islocal", true);
        hashtable.Add("oncomplete", "OnSwapGunComplete");
        hashtable.Add("oncompletetarget", gameObject);
        iTween.RotateTo(gameObject, hashtable);     
        
    }
Ejemplo n.º 2
0
    public void OnSwapGunBegin(BaseActor baseActor)
    {
        if (Global.Instance.battle.BattleUI.GetComponent<BattleUI>().Center.GetComponent<Button_Center>().fireControl.isPress)
                return;
        if (_eESwapGunState != ESwapGunState.END)
            return;

        if (_eESwapBulletState != ESwapBulletState.END)
            return;

        this.baseActor = baseActor;
        _eESwapGunState = ESwapGunState.DOWN;

        iTween.StopByName(baseActor.info.m_GunList[baseActor.info.useGunIndex].info.obj, "Swap_gun_down");
        iTween.StopByName(baseActor.info.m_GunList[baseActor.info.useGunIndex].info.obj, "Swap_gun_up");

        Hashtable hashtable = new Hashtable();
        hashtable.Add("name", "Swap_gun_down");
        hashtable.Add("time", 0.275f);
        hashtable.Add("x", 30.0f);
        hashtable.Add("islocal", true);
        hashtable.Add("oncomplete", "OnSwapGunModel");
        hashtable.Add("oncompletetarget", gameObject);
        iTween.RotateTo(gameObject, hashtable);

        //发消息
        LoginMsg.C2S_Actor_Animation msg = new LoginMsg.C2S_Actor_Animation();
        msg.animatiom = "SwapGun";
        msg.roomNum = baseActor.info.roomID;
        baseActor.info.sendAnimationNum++;
        msg.num = baseActor.info.sendAnimationNum;

        LoginServerManager.Instance.Server.SendMessage(baseActor.info.guid, ICmdNum.CmdNum.CS_Actor_Animation, msg, LoginServerManager.Instance.sendTime.interval_3, LoginServerManager.Instance.sendTime.count_3);
        
        //动画
        baseActor.info.obj.GetComponent<AnimationControl>().SwapGun();        
    }
Ejemplo n.º 3
0
 public void OnSwapGunComplete()
 {
     iTween.StopByName(baseActor.info.m_GunList[baseActor.info.useGunIndex].info.obj, "Swap_gun_up");
     _eESwapGunState = ESwapGunState.END;
     //TweenRotation tweenRotation = baseActor.info.swapGunPoint.GetComponent<TweenRotation>();
     //tweenRotation.enabled = false;
 }