コード例 #1
0
ファイル: Unit.cs プロジェクト: tuita520/clash-royale-clone
        public void Initialize(KingTower owner)
        {
            m_Owner = owner;

            m_Renderer.material.color = m_Owner.Definition.Color;

            m_State         = UnitState.Idle;
            m_CurrentHealth = m_MaxHealth;

            GameObject healthPanel = Instantiate
                                     (
                m_HealthPanelPrefab,
                Camera.main.WorldToScreenPoint(this.transform.position) + Vector3.up * m_HPBarYOffPx,
                Quaternion.identity,
                GameObject.Find("HUD").transform
                                     );

            healthPanel.GetComponent <UnitHealthPanel>().Initialize(this, m_HPBarYOffPx);

            m_HPBarForeground       = healthPanel.transform.GetChild(1).GetComponent <Image>();
            m_HPBarForeground.color = m_Owner.Definition.Color;

            HealthChangeEvent += OnHealthChange;

            m_Enabled = true;
        }
コード例 #2
0
        public void Initialize(KingTower owner)
        {
            m_Owner = owner;

            //m_Renderer.material.color = m_Owner.Definition.Color;
            //m_Renderer.material.color = Color.blue;

            m_State         = UnitState.Idle;
            m_CurrentHealth = m_MaxHealth;

            /*GameObject healthPanel = Instantiate
             * (
             *  m_HealthPanelPrefab,
             *  Camera.main.WorldToScreenPoint(this.transform.position) + Vector3.up * m_HPBarYOffPx,
             *  Quaternion.identity
             *  //GameObject.Find("HUD").transform
             * );
             *
             * healthPanel.GetComponent<UnitHealthPanel>().Initialize(this, m_HPBarYOffPx);
             *
             * m_HPBarForeground = healthPanel.transform.GetChild(1).GetComponent<Image>();
             * //m_HPBarForeground.color = m_Owner.Definition.Color;
             * //m_HPBarForeground.color = Color.blue;
             *
             * HealthChangeEvent += OnHealthChange;
             */
            m_Enabled = true;

            //GetComponent<Rigidbody>().velocity = new Vector3(0, 1, 0);
        }