Inheritance: NetworkBehaviour
Exemple #1
0
 private void Awake()
 {
     ptp = transform.parent.transform.parent.gameObject.GetComponent <PlayerTankParameter>();
     this.shotSpeedMagni  = ptp.GetShotSpeedMagni();
     this.ableBeBulletNum = ptp.GetShotAbleBulletNum();
     tm = this.transform.root.gameObject.GetComponent <TankMovement>();
 }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        m_Timer += Time.deltaTime;
        GameObject enemyTank = GetEnemyTank(m_TargetTank);

        if (enemyTank)
        {
            transform.position = m_IsAttachedtoTargetTank ? enemyTank.transform.position : Vector3.MoveTowards(transform.position, enemyTank.transform.position, .07f);
            TankMovement enemyMovement = enemyTank.GetComponent <TankMovement>();
            if (m_IsAttachedtoTargetTank)
            {
                Attack(ref enemyTank, ref enemyMovement);
            }
            else   //swarm is moving towards target
            {
                ToggleAliensShooting(false);
                enemyMovement.m_AliensSlowingSpeed = false;
            }
            if (m_Timer > m_LifeTime)
            {
                enemyMovement.m_AliensSlowingSpeed = false;
                Destroy(gameObject);
            }
        }
        else
        {
            Destroy(gameObject);
        }
    }
Exemple #3
0
 private void Awake()
 {
     // init references
     movement  = GetComponentInParent <TankMovement>();
     rb        = GetComponentInParent <Rigidbody>();
     myGrabber = GetComponentInChildren <Grabber>();
 }
    public void Setup()
    {
        // Get references to the components.
        m_Movement = m_Instance.GetComponent<TankMovement>();
        m_Shooting = m_Instance.GetComponent<TankShooting>();
        m_Percepts = m_Instance.GetComponent<TankPercepts>();
        m_Health = m_Instance.GetComponent<TankHealth>();
        m_CanvasGameObject = m_Instance.GetComponentInChildren<Canvas>().gameObject;

        // Set the player numbers to be consistent across the scripts.
        m_Movement.m_PlayerNumber = pid;
        m_Shooting.m_PlayerNumber = pid;

        // Create a string using the correct color that says 'PLAYER 1' etc based on the tank's color and the player's number.
        m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_PlayerColor) + ">PLAYER " + pid + "</color>";
        m_Instance.name = "Tank - Player " + pid;

        // Get all of the renderers of the tank.
        MeshRenderer[] renderers = m_Instance.GetComponentsInChildren<MeshRenderer>();

        // Go through all the renderers...
        for (int i = 0; i < renderers.Length; i++)
        {
            // ... set their material color to the color specific to this tank.
            renderers[i].material.color = m_PlayerColor;
        }
    }
Exemple #5
0
        protected virtual void Update()
        {
            GameManager gameManager = GameManager.s_Instance;

            if (gameManager != null && gameManager.rulesProcessor != null)
            {
                if (gameManager.rulesProcessor.IsEndOfRound())
                {
                    m_DisableFire = true;
                }
            }

            if (m_FollowPlayer && !m_HasGotPlayer && gameManager != null)
            {
                if (GameManager.s_Tanks.Count > 0)
                {
                    TankManager tank = GameManager.s_Tanks[0];

                    m_FollowTransforms.Add(tank.transform);
                    m_TankToFollowMovement = tank.movement;
                    m_PlayerTankIndex      = m_FollowTransforms.Count - 1;
                    m_HasGotPlayer         = true;
                }
            }

            if (!m_DisableFire)
            {
                DoTargeting();
                RotateTurret();
                RangeCheck();
                AssessAndFire();
            }
        }
Exemple #6
0
    // Use this for initialization
    public void SetUp()
    {
        MovementScript = ObjectReference.GetComponent <TankMovement>();
        ShootScript    = ObjectReference.GetComponent <TankShoot>();
        NameScript     = ObjectReference.GetComponent <PlayerName>();
        LineRender     = ObjectReference.GetComponent <LineRenderer>();

        MovementScript.PlayerNum = PlayerNum;
        ShootScript.PlayerNum    = PlayerNum;
        NameScript.Name          = NameScript.Name + " " + PlayerNum;

        LineRender.material = PlayerMaterial;

        // Get all of the renderers of the tank.
        MeshRenderer[] Renderers = ObjectReference.GetComponentsInChildren <MeshRenderer>();

        // Go through all the renderers...
        for (int i = 0; i < Renderers.Length; i++)
        {
            // ... set their material color to the color specific to this tank.
            if (Renderers[i].name != "MeshText")
            {
                Renderers[i].material = PlayerMaterial;
            }
        }
    }
Exemple #7
0
    public void Setup()
    {
        m_Instance.GetComponent <Collider>().enabled = isPlayer;
        // Get references to the components.
        m_movement         = m_Instance.GetComponent <TankMovement>();
        m_shooting         = m_Instance.GetComponent <TankShooting>();
        m_health           = m_Instance.GetComponent <TankHealth>();
        m_propBehavior     = m_Instance.GetComponent <TankPropBehavior>();
        m_CanvasGameObject = m_Instance.GetComponentInChildren <Canvas>().gameObject;

        m_movement.m_avatar          = m_avatar;
        m_shooting.m_isPlayer        = isPlayer;
        m_shooting.m_tankmanager     = this;
        m_propBehavior.m_isPlayer    = isPlayer;
        m_propBehavior.m_tankmanager = this;

        m_health.SetIDText(m_avatarName);
        // Create a string using the correct color that says 'PLAYER 1' etc based on the tank's color and the player's number.
        m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_PlayerColor) + ">PLAYER " + m_PlayerNumber + "</color>";

        // Get all of the renderers of the tank.
        MeshRenderer[] renderers = m_Instance.GetComponentsInChildren <MeshRenderer>();

        // Go through all the renderers...
        for (int i = 0; i < renderers.Length; i++)
        {
            // ... set their material color to the color specific to this tank.
            renderers[i].material.color = m_PlayerColor;
        }
    }
Exemple #8
0
    public void Setup()
    {
        // Get references to the components.
        m_Movement = m_Instance.GetComponent<TankMovement>();
        m_Shooting = m_Instance.GetComponent<TankShooting>();
        m_Health = m_Instance.GetComponent<TankHealth>();
        m_Setup = m_Instance.GetComponent<TankSetup>();

        // Get references to the child objects.
        m_TankRenderers = m_Health.m_TankRenderers;

        //Set a reference to that amanger in the health script, to disable control when dying
        m_Health.m_Manager = this;

        // Set the player numbers to be consistent across the scripts.
        m_Movement.m_PlayerNumber = m_PlayerNumber;
        m_Movement.m_LocalID = m_LocalPlayerID;

        m_Shooting.m_PlayerNumber = m_PlayerNumber;
        m_Shooting.m_localID = m_LocalPlayerID;

        //setup is use for diverse Network Related sync
        m_Setup.m_Color = m_PlayerColor;
        m_Setup.m_PlayerName = m_PlayerName;
        m_Setup.m_PlayerNumber = m_PlayerNumber;
        m_Setup.m_LocalID = m_LocalPlayerID;
    }
Exemple #9
0
    public float distanceToFlag; //can change to public getter and setters instead

    public void Setup(Transform spawnPoint, Transform flag, GenerateMaze generateMaze)
    {
        //sets random spawn point for tank
        this.spawnPoint = m_SpawnPoint.position;
        m_GenerateMaze  = generateMaze;

        m_Movement = m_Instance.GetComponent <TankMovement>();
        m_Movement.m_PlayerNumber = teamNumber;

        m_Shooting = m_Instance.GetComponent <TankShooting>();
        m_Shooting.m_PlayerNumber = teamNumber;

        //UI Healthbar manager
        m_Health                 = m_Instance.GetComponent <TankHealth>();
        healthCanvas             = GameObject.FindGameObjectWithTag("HealthBar" + teamNumber);
        m_Health.ui_HealthSlider = healthCanvas.GetComponentInChildren <Slider>();

        //Kill count Ui manager
        killCountCanvas = GameObject.FindGameObjectWithTag("KillCount" + teamNumber);
        killCount       = killCountCanvas.GetComponent <Text>();
        killCount.text  = "KILL COUNT: " + getKillCount().ToString();//Not updating for some reason

        // Observation
        m_tankObservation = m_Instance.GetComponent <TankObservation>();
        m_tankObservation.SetFlag(flag);

        m_Instance.GetComponentsInChildren <ScreenshotHandler>()[0].SetScreenshotName($"Player{teamNumber}");


        // Player server
        m_playerServer = new PlayerServer();

        m_Movement.m_PlayerNumber = m_PlayerNumber;
        m_Shooting.m_PlayerNumber = m_PlayerNumber;

        m_CanvasGameObject = m_Instance.GetComponentInChildren <Canvas>().gameObject;

        if (teamNumber == 1)
        {
            m_PlayerColor = Color.red;
        }
        else if (teamNumber == 2)
        {
            m_PlayerColor = Color.blue;
        }
        else //this one shouldn't matter so long as I did the mod operation correctly
        {
            m_PlayerColor = Color.black;
        }

        m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_PlayerColor) + ">TEAM " + teamNumber + "</color>"; //html like text to handle the text colour

        MeshRenderer[] renderers = m_Instance.GetComponentsInChildren <MeshRenderer>();                                      //gets all mesh renderers in tank prefab

        //set all renderers in tank's meshrenderers to the player's colour
        for (int i = 0; i < renderers.Length; i++)
        {
            renderers[i].material.color = m_PlayerColor;
        }
    }
Exemple #10
0
 private void Awake()
 {
     _movement = gameObject.GetComponent <TankMovement>();
     _shooting = gameObject.GetComponent <TankShooting>();
     instance  = gameObject;
     Setup();
 }
Exemple #11
0
    public void Setup()
    {
        // Get references to the components.
        m_Movement = m_Instance.GetComponent <TankMovement>();
        m_Shooting = m_Instance.GetComponent <TankShooting>();
        m_Health   = m_Instance.GetComponent <TankHealth>();
        m_Setup    = m_Instance.GetComponent <TankSetup>();

        // Get references to the child objects.
        m_TankRenderers = m_Health.m_TankRenderers;

        //Set a reference to that amanger in the health script, to disable control when dying
        m_Health.m_Manager = this;

        // Set the player numbers to be consistent across the scripts.
        m_Movement.m_PlayerNumber = m_PlayerNumber;
        m_Movement.m_LocalID      = m_LocalPlayerID;

        m_Shooting.m_PlayerNumber = m_PlayerNumber;
        m_Shooting.m_localID      = m_LocalPlayerID;

        //setup is use for diverse Network Related sync
        m_Setup.m_Color        = m_PlayerColor;
        m_Setup.m_PlayerName   = m_PlayerName;
        m_Setup.m_PlayerNumber = m_PlayerNumber;
        m_Setup.m_LocalID      = m_LocalPlayerID;
    }
Exemple #12
0
    void onPlay(SocketIOEvent socketIOEvent)
    {
        string     data            = socketIOEvent.data.ToString();
        UserJSON   currentUserData = UserJSON.CreateFromJSON(data);
        Vector3    position        = new Vector3(currentUserData.position [0], currentUserData.position [1], currentUserData.position [2]);
        Quaternion rotation        = Quaternion.Euler(0f, currentUserData.rotation, 0f);
        Color      playerColor;

        ColorUtility.TryParseHtmlString(currentUserData.playerColor, out playerColor);

        GameObject p = Instantiate(player, position, rotation) as GameObject;

        p.name = currentUserData.name;

        TankShooting shooting = p.GetComponent <TankShooting> ();

        shooting.isLocalPlayer = true;
        shooting.playerName    = currentUserData.name;

        TankMovement movement = p.GetComponent <TankMovement> ();

        movement.isLocalPlayer = true;

        MeshRenderer[] renderers = p.GetComponentsInChildren <MeshRenderer> ();
        for (int i = 0; i < renderers.Length; i++)
        {
            renderers[i].material.color = playerColor;
        }
    }
Exemple #13
0
    public override void Awake()
    {
        base.Awake();

        TankHealth tankHealth = tankInfo.tankHealth;

        tankHealth.m_StartingHealth  = tankSetting.StartingHealth;
        tankHealth.m_FullHealthColor = tankSetting.FullHealthColor;
        tankHealth.m_ZeroHealthColor = tankSetting.ZeroHealthColor;
        tankHealth.m_ExplosionPrefab = tankSetting.ExplosionPrefab;

        TankShootingBase tankShooting = tankInfo.tankShooting;

        tankShooting.m_ChargingClip   = tankSetting.ChargingClip;
        tankShooting.m_FireClip       = tankSetting.FireClip;
        tankShooting.m_MinLaunchForce = tankSetting.MinLaunchForce;
        tankShooting.m_MaxLaunchForce = tankSetting.MaxLaunchForce;
        tankShooting.m_MaxChargeTime  = tankSetting.MaxChargeTime;
        tankShooting.delayTime        = tankSetting.DelayTime;

        TankMovement tankMovement = tankInfo.tankMovement;

        tankMovement.m_Speed         = tankSetting.Speed;
        tankMovement.m_TurnSpeed     = tankSetting.TurnSpeed;
        tankMovement.m_EngineIdling  = tankSetting.EngineIdling;
        tankMovement.m_EngineDriving = tankSetting.EngineDriving;
        tankMovement.m_PitchRange    = tankSetting.PitchRange;
    }
Exemple #14
0
    void OnOtherPlayerConnected(SocketIOEvent socketIOEvent)
    {
        print("Someone else joined");
        string     data     = socketIOEvent.data.ToString();
        UserJSON   userJSON = UserJSON.CreateFromJSON(data);
        Vector3    position = new Vector3(float.Parse(userJSON.position[0]), float.Parse(userJSON.position[1]), float.Parse(userJSON.position[2]));
        Quaternion rotation = Quaternion.Euler(float.Parse(userJSON.rotation[0]), float.Parse(userJSON.rotation[1]), float.Parse(userJSON.rotation[2]));
        GameObject o        = GameObject.Find(userJSON.name) as GameObject;

        if (o != null)
        {
            return;
        }
        GameObject p = Instantiate(player, position, rotation) as GameObject;
        // here we are setting up their other fields name and if they are local
        TankMovement pc = p.GetComponent <TankMovement>();

        //Transform t = p.transform.Find("Healthbar Canvas");
        //Transform t1 = t.transform.Find("Player Name");
        //Text playerName = t1.GetComponent<Text>();
        //playerName.text = userJSON.name;
        pc.isLocalPlayer = false;
        p.name           = userJSON.name;
        p.transform.Find("HealthCanvas").Find("NameText").GetComponent <Text>().text = userJSON.name;
        // we also need to set the health
        Health h = p.GetComponent <Health>();

        h.currentHealth = userJSON.health;
        h.OnChangeHealth();
    }
Exemple #15
0
    public void Setup()
    {
        // Get references to the components.
        m_Movement         = m_Instance.GetComponent <TankMovement>();
        m_Shooting         = m_Instance.GetComponent <TankShooting>();
        m_NetworkHelper    = m_Instance.GetComponent <NetworkHelper>();
        m_CanvasGameObject = m_Instance.GetComponentInChildren <Canvas>().gameObject;

        // Set the player numbers to be consistent across the scripts.
        m_Movement.m_PlayerNumber = m_PlayerNumber;
        m_Shooting.m_PlayerNumber = m_PlayerNumber;

        // Create a string using the correct color that says 'PLAYER 1' etc based on the tank's color and the player's number.
        m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_PlayerColor) + ">PLAYER " + m_PlayerNumber + "</color>";

        // Get all of the renderers of the tank.
        MeshRenderer[] renderers = m_Instance.GetComponentsInChildren <MeshRenderer>();

        // Go through all the renderers...
        for (int i = 0; i < renderers.Length; i++)
        {
            // ... set their material color to the color specific to this tank.
            renderers[i].material.color = m_PlayerColor;
        }
    }
Exemple #16
0
 private void Awake()
 {
     m_MovementScript = GetComponent <TankMovement>();
     m_ShootingScript = GetComponent <TankShooting>();
     m_HealthScript   = GetComponent <TankHealth>();
     m_RadarScript    = GetComponent <TankRadar>();
     m_Agent          = GetComponent <NavMeshAgent>();
 }
Exemple #17
0
 private void Start()
 {
     if (!OptionManager.isButton)
     {
         shotButton.SetActive(false);
     }
     tankMovementSc = GameObject.FindGameObjectWithTag("Player").GetComponent <TankMovement>();
 }
Exemple #18
0
    private void Awake()
    {
        m_tankMovement = GetComponent <TankMovement>();
        m_tankTurret   = GetComponent <TankTurret>();
        m_cannon       = GetComponent <CannonWeapon>();

        m_currentHp = m_maxHp;
    }
Exemple #19
0
    // Use this for initialization
    void Start()
    {
        TankMovement pc = GetComponent <TankMovement>();

        isLocalPlayer = pc.isLocalPlayer;

        explosionSound = GameObject.Find("explosionSound").GetComponent <AudioSource>();
    }
Exemple #20
0
    private BoxCollider m_Collider;                 // Used so that the tank doesn't collide with anything when it's dead.

    private void Awake()
    {
        m_Collider     = GetComponent <BoxCollider>();
        m_gameManager  = FindObjectOfType <GameManager>();
        m_TankMovement = GetComponent <TankMovement>();
        m_TankSetup    = GetComponent <TankSetup>();
        OnCurrentHealthChanged(m_StartingHealth);
    }
Exemple #21
0
 // Start is called before the first frame update
 void Awake()
 {
     dead           = false;
     regenerating   = false;
     energyMax      = energy;
     playerCollider = GameObject.FindGameObjectWithTag("Player").GetComponent <BoxCollider2D>();
     moveScript     = GetComponent <TankMovement>();
 }
Exemple #22
0
    void OnTriggerEnter(Collider col)
    {
        TankMovement tankCol = col.transform.GetComponent <TankMovement>();

        if (tankCol != null)
        {
            tankCol.ReFuel();
        }
    }
Exemple #23
0
    /// <summary>
    /// Gives the player bonus movespeed and turn speed;
    /// </summary>
    private void BonusSpeed()
    {
        TankMovement tm = _rb.GetComponent <TankMovement>();

        tm.m_Speed     += _speedAdd;
        tm.m_TurnSpeed += _turnAdd;

        Destroy(gameObject);
    }
Exemple #24
0
    void Awake()
    {
        _playerAudio = GetComponent <AudioSource>();
        _movement    = GetComponent <TankMovement>();
        _gun         = GetComponentInChildren <TimedGun>();

        health = startingHealth;
        _startingHealthIconColour = healthIcon.color;
    }
Exemple #25
0
    public void Init(TankMovement movement, Material material)
    {
        _movement = movement;
        m_TankRenderers[0].material = material;
        var materials = m_TankRenderers[1].materials;

        materials[1] = material;
        m_TankRenderers[1].materials = materials;
    }
Exemple #26
0
 // Use this for initialization
 void Start()
 {
     cameraFollow = GameObject.FindObjectOfType <Camera>().GetComponent <CameraFollow>();
     UpdateCameraTrack();
     renderer     = gameObject.GetComponent <SpriteRenderer>();
     tankMovement = gameObject.GetComponent <TankMovement>();
     weaponSystem = gameObject.GetComponent <TankWeaponSystem>();
     SetParameter(0, BLU);
 }
Exemple #27
0
 void OnCollisionEnter(Collision target)
 {
     if (target.gameObject.tag == "Player")
     {
         tm       = target.gameObject.GetComponent <TankMovement>();
         tm.nitro = true;
         tm.speed = 20f;
     }
 }
    private void Start()
    {
        // The fire axis is based on the player number.
        m_FireButton = "Fire" + (m_localID + 1);

        // The rate that the launch force charges up is the range of possible forces by the max charge time.
        m_ChargeSpeed = (m_MaxLaunchForce - m_MinLaunchForce) / m_MaxChargeTime;

        tankMovement = gameObject.GetComponent <TankMovement> ();
    }
Exemple #29
0
        //This method is called during setup, and subscribes all the HUD's listener methods to the local player's tank
        public void InitHudPlayer(TankManager playerTank)
        {
            m_TankManager = playerTank;
            m_Movement    = m_TankManager.movement;

            m_TankManager.onPickupCollected += OnPickupTextChanged;
            m_TankManager.onCurrencyChanged += UpdatePickUpCurrency;

            SetHudEnabled(false);
        }
Exemple #30
0
    private GameObject m_CanvasGameObject;                  // Used to disable the world space UI during the Starting and Ending phases of each round.


    public void Setup()
    {
        // Get references to the components.
        m_Movement         = m_Instance.GetComponent <TankMovement>();
        m_Shooting         = m_Instance.GetComponent <TankShooting>();
        m_CanvasGameObject = m_Instance.GetComponentInChildren <Canvas>().gameObject;


        // Atribuindo a cor escolhida pelo usuário ao tank
        // Verifica se o jogador 1 já teve cor atribuida
        // Se sim, atribui a cor para o 2° player
        if (1 == m_PlayerNumber)
        {
            ColorUtility.TryParseHtmlString("#" + PlayerPrefs.GetString("Player1"), out m_PlayerColor);
        }
        else
        {
            ColorUtility.TryParseHtmlString("#" + PlayerPrefs.GetString("Player2"), out m_PlayerColor);
        }


        // Set the player numbers to be consistent across the scripts.
        m_Movement.m_PlayerNumber = m_PlayerNumber;
        m_Shooting.m_PlayerNumber = m_PlayerNumber;

        Color botColorref = RandomColorGenerator();

        if (m_Instance.layer == LayerMask.NameToLayer("Players"))
        {
            // Create a string using the correct color that says 'PLAYER 1' etc based on the tank's color and the player's number.
            m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGBA(m_PlayerColor) + ">PLAYER " + m_PlayerNumber + "</color>";
        }
        else
        {
            // Create a string using the correct color that says 'Bot 1' etc based on the tank's color and the Bot's number.
            m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGBA(botColorref) + ">Bot " + m_PlayerNumber + "</color>";
        }

        // Get all of the renderers of the tank.
        MeshRenderer[] renderers = m_Instance.GetComponentsInChildren <MeshRenderer>();

        // Go through all the renderers...
        for (int i = 0; i < renderers.Length; i++)
        {
            // ... set their material color to the color specific to this tank.
            if (m_Instance.layer == LayerMask.NameToLayer("Players"))
            {
                renderers[i].material.color = m_PlayerColor;
            }
            else
            {
                renderers[i].material.color = botColorref;
            }
        }
    }
Exemple #31
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         tm = other.gameObject.GetComponent <TankMovement>();
         tm.SpeedUp(2f);
         Destroy(gameObject);
         GameObject effect = (GameObject)Instantiate(effectPrefab, transform.position, Quaternion.identity);
         Destroy(effect, 0.7f);
     }
 }
    private void Awake()
    {
        TankMovement movement = GetComponent <TankMovement> ();

        isLocalPlayer = movement.isLocalPlayer;

        m_ExplosionParticles = Instantiate(m_ExplosionPrefab).GetComponent <ParticleSystem>();
        m_ExplosionAudio     = m_ExplosionParticles.GetComponent <AudioSource>();

        m_ExplosionParticles.gameObject.SetActive(false);
    }
Exemple #33
0
 private void Attack(ref GameObject enemyTank, ref TankMovement enemyMovement)
 {
     m_AttackTimer += Time.deltaTime;
     ToggleAliensShooting(true);
     enemyMovement.m_AliensSlowingSpeed = true;
     if (!transform.GetChild(0).GetComponent<Light>().enabled)
     {
         Transform endLight = transform.GetChild(0);
         endLight.GetComponent<Light>().enabled = true;
     }
     if (m_AttackTimer > m_AttackInterval)
     {
         m_AttackTimer = 0.0f;
         enemyTank.GetComponent<TankHealth>().TakeDamage(m_Damage);
     }
 }
Exemple #34
0
    public void Setup(){
        m_Movement = m_Instance.GetComponent<TankMovement>();
        m_Shooting = m_Instance.GetComponent<TankShooting>();
        m_CanvasGameObject = m_Instance.GetComponentInChildren<Canvas>().gameObject;

        m_Movement.m_PlayerNumber = m_PlayerNumber;
        m_Shooting.m_PlayerNumber = m_PlayerNumber;

        m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_PlayerColor) + ">PLAYER " + m_PlayerNumber + "</color>";

        MeshRenderer[] renderers = m_Instance.GetComponentsInChildren<MeshRenderer>();

        for (int i = 0; i < renderers.Length; i++){
            renderers[i].material.color = m_PlayerColor;
        }
    }
    public TankEffect m_Effect;                        // Reference to tank's movement script, used to disable and enable control.



    public void Setup(int type)
    {
        // Get references to the components.
        m_Movement = m_Instance.GetComponent<TankMovement>();
        m_Shooting = m_Instance.GetComponent<TankShooting>();
        m_Health = m_Instance.GetComponent<TankHealth>();
        m_Effect = m_Instance.GetComponent<TankEffect>();

        // Set the player numbers to be consistent across the scripts.
        m_Movement.m_PlayerNumber = m_PlayerNumber;
        m_Shooting.m_PlayerNumber = m_PlayerNumber;
        m_Health.m_PlayerNumber = m_PlayerNumber;
        m_Effect.m_PlayerNumber = m_PlayerNumber;

        m_Movement.m_PlayerType = type;
        m_Shooting.m_PlayerType = type;
        m_Health.m_PlayerType = type;
        m_Effect.m_PlayerType = type;

        if (m_PlayerNumber == 1 || m_PlayerNumber == 2)
        {
            m_Shooting.m_CurrentFireDame = 1;
            m_Shooting.m_CurrentFireSpeed = 25;
            m_Movement.m_Speed = 12;
        }
        else {
            if (m_Movement.m_PlayerType == 0)//normal
            {
                m_Shooting.m_CurrentFireDame = 1;
                m_Shooting.m_CurrentFireSpeed = 25;
                m_Movement.m_Speed = 10;
            }
            else if (m_Movement.m_PlayerType == 1)//fast
            {
                m_Shooting.m_CurrentFireDame = 1;
                m_Shooting.m_CurrentFireSpeed = 30;
                m_Movement.m_Speed = 14;
            }
            else if (m_Movement.m_PlayerType == 2)//power
            {
                m_Shooting.m_CurrentFireDame = 1;
                m_Shooting.m_CurrentFireSpeed = 35;
                m_Movement.m_Speed = 12;
            }
            else if (m_Movement.m_PlayerType == 3)//armo
            {
                m_Shooting.m_CurrentFireDame = 1;
                m_Shooting.m_CurrentFireSpeed = 30;
                m_Movement.m_Speed = 8;
            }

        }

        m_Health.m_CurrentLive = 3;

        // Create a string using the correct color that says 'PLAYER 1' etc based on the tank's color and the player's number.
        if (m_PlayerNumber != 0)
        {
            m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_PlayerColor) + ">PLAYER " + m_PlayerNumber + "</color>";
        }
        else
        {
            m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(Color.grey) + ">ENEMY</color>";
        }

        // Get all of the renderers of the tank.
        MeshRenderer[] renderers = m_Instance.GetComponentsInChildren<MeshRenderer>();

        // Go through all the renderers...
        for (int i = 0; i < renderers.Length; i++)
        {
            // ... set their material color to the color specific to this tank.
            if (m_PlayerNumber == 1 || m_PlayerNumber == 2)
                renderers[i].material.color = m_PlayerColor;
            else if (m_Shooting.m_PlayerType != 1)
                renderers[i].material.color = Color.grey;

        }
        m_Effect.initEffect(this);

        if (m_PlayerNumber == 1 || m_PlayerNumber == 2)
        {
            m_Shooting.m_Star = GameObject.Instantiate(GameManager.m_Instancce.m_StarFrefab, m_Health.transform.position, Quaternion.identity) as GameObject;
            m_Shooting.m_Star.transform.position = new Vector3(m_Shooting.m_Star.transform.position.x, 2, m_Shooting.m_Star.transform.position.z);
            m_Shooting.m_Star.transform.parent = m_Health.transform;

            if (m_PlayerNumber == 1)
                m_Shooting.InitNewStar(GameManager.m_TanksStarSave[0]);
            else
                m_Shooting.InitNewStar(GameManager.m_TanksStarSave[1]);
        }

        //if (!SoundEngine.m_isSoundEnable)
       // {
        //    m_Movement.m_MovementAudio.enabled = false;
       // }
       // else
        //    m_Movement.m_MovementAudio.enabled = true;
    }
 public void SetMovementScipt(TankMovement m_Movement)
 {
     this.m_Movement = m_Movement;
 }