コード例 #1
0
        /// <summary>
        /// 为一个Unit分配阵营
        /// </summary>
        public void AllocRoleCamp(Unit unit)
        {
            B2S_RoleCastComponent b2SRoleCastComponent = unit.GetComponent <B2S_RoleCastComponent>();

            if (b2SRoleCastComponent == null)
            {
                return;
            }
            if (TianZaiCount > this.HuiYueCount)
            {
                b2SRoleCastComponent.RoleCamp = RoleCamp.HuiYue;
                HuiYueCount++;
            }
            else
            {
                b2SRoleCastComponent.RoleCamp = RoleCamp.TianZai;
                HuiYueCount--;
            }
        }
コード例 #2
0
        public void Update()
        {
            //此处填写Update逻辑
            if (m_MouseTargetSelectorComponent.TargetUnit != null)
            {
                B2S_RoleCastComponent roleCastComponent = m_MouseTargetSelectorComponent.TargetUnit.GetComponent <B2S_RoleCastComponent>();
                if (roleCastComponent == null)
                {
                    ResetUnitOutLineInfo(m_CachedUnit);
                    m_CachedUnit = null;
                    return;
                }

                if (m_CachedUnit != m_MouseTargetSelectorComponent.TargetUnit)
                {
                    ResetUnitOutLineInfo(m_CachedUnit);
                    m_CachedUnit = m_MouseTargetSelectorComponent.TargetUnit;
                    GameObject selfUnitGo = m_CachedUnit.GameObject;
                    selfUnitGo.GetRCInternalComponent <Renderer>("Materials").GetPropertyBlock(s_MaterialPropertyBlock);
                    s_MaterialPropertyBlock.SetInt("OutLineWidth", 5);
                    if (roleCastComponent.RoleCast == RoleCast.Friendly)
                    {
                        s_MaterialPropertyBlock.SetColor("OutLineColor", Color.blue);
                    }
                    else
                    {
                        s_MaterialPropertyBlock.SetColor("OutLineColor", Color.red);
                    }

                    selfUnitGo.GetRCInternalComponent <Renderer>("Materials").SetPropertyBlock(s_MaterialPropertyBlock);
                }
            }
            else
            {
                ResetUnitOutLineInfo(m_CachedUnit);
                m_CachedUnit = null;
            }
        }