Exemplo n.º 1
0
    public void WeaponOperationByHotKey(SkillHotkey skillHotkey)
    {
        if (m_PlayerSkillProxy.UsingReformer())
        {
            SkillCastEvent castSkillEvent = new SkillCastEvent();
            castSkillEvent.IsWeaponSkill = true;
            castSkillEvent.SkillIndex    = skillHotkey.SkillIndex;
            castSkillEvent.KeyPressed    = skillHotkey.ActionPhase == HotkeyPhase.Started;

//#if NewSkill
//#else
            m_MainPlayer.SendEvent(ComponentEventName.CastSkill, castSkillEvent);
//#endif
        }
        else
        {
            WeaponOperationImplementation(skillHotkey);
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 主武器改变时
    /// </summary>
    private void OnMainWeaponChanged()
    {
        m_lastFireFail = false;

        m_CurrentTargetList.Clear();

        m_Crosshair = null;
        m_Point = null;
        m_Frame = null;
        m_FrameBox = null;
        m_TargetBox = null;

        for (int i = 0; i < m_Root.childCount; i++)
        {
            m_Root.GetChild(i).gameObject.SetActive(false);
        }

        PlayerSkillProxy skillProxy = Facade.RetrieveProxy(ProxyName.PlayerSkillProxy) as PlayerSkillProxy;

        IWeapon currentWeapon = skillProxy.GetCurrentWeapon();

        m_WeaponStyle = (int)WeaponAndCrossSight.WeaponAndCrossSightTypes.Null;
        m_AutoLockEnabled = currentWeapon != null && currentWeapon.GetConfig().AssistKey != 0;

        SpacecraftEntity main = GetMainEntity();
        if (main && IsBattling())
        {
            IReformer reformer = skillProxy.UsingReformer() ? skillProxy.GetReformer() : null;

            if (reformer != null)
                m_WeaponStyle = (WeaponAndCrossSight.WeaponAndCrossSightTypes)reformer.GetConfig().Reticle;
            else if (currentWeapon != null)
                m_WeaponStyle = (WeaponAndCrossSight.WeaponAndCrossSightTypes)currentWeapon.GetConfig().Reticle;
        }

        m_Crosshair = m_Root.GetChild((int)m_WeaponStyle).GetComponent<RectTransform>();
       // m_Crosshair.gameObject.SetActive(true);
        m_Point = m_Crosshair.Find("point") != null ? m_Crosshair.Find("point").GetComponent<RectTransform>() : null;
        m_Frame = m_Crosshair.Find("frame") != null ? m_Crosshair.Find("frame").GetComponent<RectTransform>() : null;
        m_FrameBox = m_Crosshair.Find("FrameBox") != null ? m_Crosshair.Find("FrameBox").GetComponent<RectTransform>() : null;
        m_TargetBox = m_Crosshair.Find("Targets") != null ? m_Crosshair.Find("Targets").GetComponent<RectTransform>() : null;
	}
    /// <summary>
    /// 转化炉切换
    /// </summary>
    /// <param name="entityEvent"></param>
    private void ReformerWeapons(IComponentEvent entityEvent)
    {
        if (m_IPerceptronTarget.GetCurrentState().IsHasSubState(EnumSubState.Peerless))
        {
            //转化炉模式
            if (!m_SkillProxy.UsingReformer())
            {
                return;
            }

            IReformer reformer = m_SkillProxy.GetReformer();
            if (reformer == null)
            {
                return;
            }
            ulong uid = reformer.GetUID();
            if (!m_IPerceptronTarget.HaveWeaponAndCrossSight(uid))
            {
                WeaponAndCrossSight weaponAndCross = WeaponAndCrossSightFactory.CreatTWeapon(uid,
                                                                                             reformer.GetConfig().Id, reformer.GetBaseConfig().SkillId,
                                                                                             (WeaponAndCrossSight.WeaponAndCrossSightTypes)reformer.GetConfig().Reticle);

                //Debug.LogError(string.Format("创建准星 uid = {0}, tid = {1} , type = {2}, null? {3}", uid, weapon.GetConfig().Id, weapon.GetConfig().Reticle , (weaponAndCross== null)));

                if (weaponAndCross == null)
                {
                    return;
                }
                m_IPerceptronTarget.AddWeaponAndCrossSight(uid, weaponAndCross);
            }
        }
        else
        {
            //非转化炉模式
            m_IPerceptronTarget.DeleReformerWeaponAndCrossSight();
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// 武器切换时
    /// </summary>
    /// <param name="hiddenRoot">是否隐藏根节点</param>
    private void OnWeaponToggleEnd(bool hiddenRoot)
    {
        m_Root.alpha = hiddenRoot ? 0 : 1;

        PlayerSkillProxy skillProxy = Facade.RetrieveProxy(ProxyName.PlayerSkillProxy) as PlayerSkillProxy;

        IWeapon currWeapon = skillProxy.GetCurrentWeapon();

        if (currWeapon != null)
        {
            IWeapon mainWeapon      = skillProxy.GetWeaponByIndex(0);
            IWeapon secondaryWeapon = skillProxy.GetWeaponByIndex(1);

            m_MainWeapon.gameObject.SetActive(true);
            m_SecondaryWeapon.gameObject.SetActive(true);

            m_MainWeapon.ResetTrigger("Big");
            m_MainWeapon.ResetTrigger("Small");

            m_SecondaryWeapon.ResetTrigger("Big");
            m_SecondaryWeapon.ResetTrigger("Small");

            m_RootAnimator.ResetTrigger("Show");
            m_RootAnimator.SetTrigger("Show");

            if (skillProxy.UsingReformer())
            {
                if (currWeapon.GetPos() == 0)
                {
                    m_MainWeapon.SetTrigger("Big");
                    m_SecondaryWeapon.SetTrigger("Small");
                    m_SecondaryWeapon.gameObject.SetActive(secondaryWeapon != null);
                }
                else if (currWeapon.GetPos() == 1)
                {
                    m_MainWeapon.SetTrigger("Small");
                    m_SecondaryWeapon.SetTrigger("Big");
                    m_MainWeapon.gameObject.SetActive(mainWeapon != null);
                }
            }
            else
            {
                if (currWeapon.GetPos() == 0)
                {
                    m_MainWeapon.SetTrigger("Big");
                    m_SecondaryWeapon.SetTrigger("Small");
                    m_SecondaryWeapon.gameObject.SetActive(secondaryWeapon != null);
                }
                else if (currWeapon.GetPos() == 1)
                {
                    m_MainWeapon.SetTrigger("Small");
                    m_SecondaryWeapon.SetTrigger("Big");
                    m_MainWeapon.gameObject.SetActive(mainWeapon != null);
                }
            }

            m_MainWeapon.gameObject.SetActive(mainWeapon != null);
            if (mainWeapon != null)
            {
                UIUtil.SetIconImage(m_MainWeaponIcon, mainWeapon.GetBaseConfig().Icon);
            }

            m_SecondaryWeaponIcon.gameObject.SetActive(secondaryWeapon != null);
            if (secondaryWeapon != null)
            {
                UIUtil.SetIconImage(m_SecondaryWeaponIcon, secondaryWeapon.GetBaseConfig().Icon);
            }
        }
        else
        {
            m_MainWeapon.gameObject.SetActive(false);
            m_SecondaryWeapon.gameObject.SetActive(false);
        }
    }
Exemplo n.º 5
0
    private void OnSkillHotkeyImplementation(SkillCastEvent skillCast)
    {
        PlayerSkillVO skillVO;

        if (skillCast.IsWeaponSkill)
        {
            if (m_SkillProxy.UsingReformer())
            {
                skillVO = m_SkillProxy.GetReformerSkill();
            }
            else
            {
                skillVO = m_SkillProxy.GetCurrentWeaponSkill();
                if (skillVO != null && !m_CfgSkillProxy.IsWeaponSkill(skillVO.GetID()))
                {
                    Debug.LogErrorFormat("技能 {0} 被配置在武器上, 但它并不是一个武器技能! 找策划确认一下技能表和武器表", skillVO.GetID());
                }
            }
        }
        else
        {
            skillVO = m_SkillProxy.GetSkillByIndex(skillCast.SkillIndex);
            if (skillVO != null && m_CfgSkillProxy.IsWeaponSkill(skillVO.GetID()))
            {
                Debug.LogErrorFormat("技能 {0} 被配置在飞船上, 但它其实是一个武器技能! 找策划确认一下技能表和武器表", skillVO.GetID());
            }
        }

        if (skillVO != null)
        {
            int skillID = skillVO.GetID();

            bool keyPressed = skillCast.KeyPressed;

            if (keyPressed && !IsReleasingSkill(skillID))
            {
                // 释放Trigger技能的过程中, 可以释放非Trigger技能. 此时Trigger技能中断, 等非Trigger技能结束后继续放
                // 不是Trigger技能的话, 每次技能按键按下, 只能释放一次
                if ((m_CfgSkillProxy.IsTriggerSkill(skillID) && !OneOfReleasingSkillsIsNotTriggerSkill()) ||
                    (!m_CfgSkillProxy.IsTriggerSkill(skillID) && !SkillHasReleasedDuringPress(skillID)))
                {
                    ReleaseSkillByClientInput(skillID);
                    SetSkillReleaseDuringPress(skillID, true);

                    if (m_CfgSkillProxy.IsTriggerSkill(skillID))
                    {
                        m_Property.SetTriggerSkillID(skillID);
                        m_Property.SetReleasingTriggerSkill(true);
                    }
                }
            }
            else
            {
                SkillControlEvent skillEvent = keyPressed ? SkillControlEvent.Event_SkillButtonPress : SkillControlEvent.Event_SkillButtonRelease;
                SendEventToSkill(skillID, skillEvent, null);

                if (!keyPressed)
                {
                    SetSkillReleaseDuringPress(skillID, false);
                    m_Property.SetReleasingTriggerSkill(false);
                    m_Property.SetTriggerSkillID(-1);
                }
            }
        }
    }
Exemplo n.º 6
0
    /// <summary>
    /// 更新武器的子弹信息
    /// </summary>
    private void UpdateWeaponBullets()
    {
        if (m_Crosshair != null && m_WeaponStyle != WeaponAndCrossSight.WeaponAndCrossSightTypes.Null)
        {
            Transform powerSlider = FindComponent<Transform>(m_Crosshair, "Slider");
            Animator powerSliderAnimator = FindComponent<Animator>(m_Crosshair, "Slider");
            if (powerSlider == null)
                return;

            PlayerSkillProxy skillProxy = Facade.RetrieveProxy(ProxyName.PlayerSkillProxy) as PlayerSkillProxy;
            if (skillProxy.UsingReformer())
            {
                powerSlider.gameObject.SetActive(false);
                return;
            }

            IWeapon currentWeapon = skillProxy.GetCurrentWeapon();
            if (currentWeapon == null)
            {
                powerSlider.gameObject.SetActive(false);
                return;
            }

            WeaponPowerVO weaponVO1 = skillProxy.GetWeaponPowerOfMainPlayer(0);
            WeaponPowerVO weaponVO2 = skillProxy.GetWeaponPowerOfMainPlayer(1);

            WeaponPowerVO power = weaponVO1 != null && skillProxy.GetWeaponByUID(weaponVO1.WeaponUID) == currentWeapon ? weaponVO1 : weaponVO2;

            float curr = 0;
            float total = 0;

			if (power != null)
			{
				if (m_WeaponStyle == WeaponAndCrossSight.WeaponAndCrossSightTypes.MachineGun  )
				{
					curr = power.CurrentValue;
					total = power.MaxValue;
				}
				else if (m_WeaponStyle == WeaponAndCrossSight.WeaponAndCrossSightTypes.Missile)
				{
					foreach (var entity in m_CurrentTargetList.Values)
					{
						curr += entity.LockTimes;
					}
                    total = MaxMissileCount;// skillProxy.GetCurrentBattleWeapon().GetRelativeHeightOfReticle().MissileCountInOneShot;
				}
				else if ((int)m_WeaponStyle ==(int)WeaponAndCrossSight.WeaponAndCrossSightTypes.ShotGun)
				{
					curr = power.CurrentValue;
					total = power.MaxValue;
				}
			}

			float weaponPowerRatio = total != 0 ? curr / total : 0;

            if (powerSliderAnimator)
            {
                if (power.ForceCooldown)
                    powerSliderAnimator.SetInteger("State", 2);
                else if (weaponPowerRatio <= 0.7f)
                    powerSliderAnimator.SetInteger("State", 0);
                else if (weaponPowerRatio > 0.7f)
                    powerSliderAnimator.SetInteger("State", 1);

                if (m_lastFireFail)
                    powerSliderAnimator.SetTrigger("FireFail");
            }

            m_lastFireFail = false;

            RadialSlider radialSlider = powerSlider.GetComponent<RadialSlider>();
            if(radialSlider)
            {
                radialSlider.FillAmount = weaponPowerRatio;
                return;
            }

            BulletSlider bulletSlider = powerSlider.GetComponent<BulletSlider>();
            if(bulletSlider)
            {
                bulletSlider.BulletCount = (int)total;
                bulletSlider.FillAmount = weaponPowerRatio;
                return;
            }

            Slider commonSlider = powerSlider.GetComponent<Slider>();
            if(commonSlider)
            {
                commonSlider.minValue = 0;
                commonSlider.maxValue = 1;
                commonSlider.value = weaponPowerRatio;
                return;
            }
        }
    }