コード例 #1
0
ファイル: PowerUpManager.cs プロジェクト: tomwallace/Tanks
        public void PowerUpColliderTriggerHit(string powerUpType, string coloredText, Collider colliderHit)
        {
            // Ensure it is a tank first
            TankMovement tankMovement = colliderHit.GetComponent <TankMovement>();

            if (tankMovement != null)
            {
                Debug.Log("Player picked up power up of type: " + powerUpType.ToString());

                string message = string.Format("Player {0} got a {1} {2}", tankMovement.m_PlayerNumber, powerUpType, coloredText);
                StartCoroutine(GameManagerInstance.SetMessageText(message));

                switch (powerUpType)
                {
                case HEALTH:
                    TankHealth tankHealth = colliderHit.GetComponent <TankHealth>();
                    // Heal them by taking negative damage
                    tankHealth.TakeDamage(-50f);
                    break;

                case SHIELD:
                    float playerShieldEnds = Time.time + PowerUpLasts;
                    StartCoroutine(MakeShield(colliderHit.gameObject, playerShieldEnds));
                    break;

                case MEGASHELL:
                    StartCoroutine(SetMegaShell(colliderHit.gameObject, PowerUpLasts));
                    break;

                default:
                    throw new MissingComponentException("PowerUp name not recognized");
                }
            }
        }
コード例 #2
0
ファイル: ShellExplosion.cs プロジェクト: Fenikkel/Tanks
    private void OnTriggerEnter(Collider other)
    {
        // Find all the tanks in an area around the shell and damage them.
        Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius, m_TankMask); //despres de entrar en el trigger, mirem quins tanks que tenen el tankMask estan o toquen la esfera que esta posicionada al punt transform.position (on esta la shell) i amb un radi de m_ExplodeRadius

        for (int i = 0; i < colliders.Length; i++)
        {
            Rigidbody targetRidbody = colliders[i].GetComponent <Rigidbody>();

            if (!targetRidbody)           //se fa per si decas, en teoria tots els tanks deurien tindre rigidbody
            {
                Debug.Log(targetRidbody); //te diu quin objecte no te rigidbody pero si la layer mask
                continue;
            }

            targetRidbody.AddExplosionForce(m_ExplosionForce, transform.position, m_ExplosionRadius);

            TankHealth targetHealth = targetRidbody.GetComponent <TankHealth>(); //targetRigitbody comparteix el mateix gameObject que el script, per aixo podem obtindre tankHealth desde el rigidbody

            float damage = CalculateDamage(targetRidbody.position);

            targetHealth.TakeDamage(damage);

            m_ExplosionParticles.transform.parent = null; //Aixina del desattachem del pare perque volem que es continue reproduint el so i les particules encara que destruim la bala. Sino destruiriem la bala i tots els seus fills

            m_ExplosionParticles.Play();

            m_ExplosionAudio.Play();

            Destroy(m_ExplosionParticles.gameObject, m_ExplosionParticles.main.duration); //destruirem el gameobject de les particules quan pase el temps de duracio de estes (que NO el lifetime de les particules)

            Destroy(gameObject);                                                          //destrueix la bala (recorda que ja no te com a fill el sistema de particules)
        }
    }
コード例 #3
0
ファイル: PlayerName.cs プロジェクト: MrMobble/SumoTank
    // Update is called once per frame
    void Update()
    {
        TextMesh.transform.rotation = Camera.main.transform.rotation;
        TankHealth TH = GetComponent <TankHealth>();

        TextMesh.color = new Color(0.95f, 0.95f - TH.GetVulnerability() * 0.05f, 0.95f - TH.GetVulnerability() * 0.05f);
    }
コード例 #4
0
    private void OnTriggerEnter(Collider other)
    {
        // Find all the tanks in an area around the shell and damage them.
        Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius, m_TankMask);

        for (int i = 0; i < colliders.Length; i++)
        {
            Rigidbody targetRigidbody = colliders[i].GetComponent <Rigidbody>();

            if (!targetRigidbody)
            {
                continue;
            }

            StartCoroutine(Pull(targetRigidbody));

            TankHealth targetHealth = targetRigidbody.GetComponent <TankHealth>();

            if (!targetHealth)
            {
                continue;
            }

            StartCoroutine(DealDamage(targetHealth));
        }

        m_ExplosionParticles.transform.parent = null;

        m_ExplosionParticles.Play();

        Destroy(m_ExplosionParticles.gameObject, 20);
        Destroy(gameObject.GetComponent <MeshFilter>());
    }
コード例 #5
0
 // Start is called before the first frame update
 void Start()
 {
     thisGameManager    = GameManager.thisManager;
     thisShipHealth     = GetComponent <TankHealth>();
     thisShipPhysic     = GetComponent <TankPhysic>();
     thisShipController = GetComponent <TankController>();
 }
コード例 #6
0
    public void TakeDamage(int damageAmount)
    {
        if (!isServer || curretHealth <= 0)
        {
            return;
        }

        curretHealth -= damageAmount;

        RpcSetHealthUI();

        if (curretHealth <= 0)
        {
            curretHealth = 0;

            RpcDied();

            if (DeatMatchManager.RemoveTankAndChekWinner(this))
            {
                TankHealth tankWinner = DeatMatchManager.GetWinner();
                tankWinner.RpcWon();
                Invoke("BackToLobbyManager", 5);
            }
            return;
        }
    }
コード例 #7
0
    private void OnTriggerEnter(Collider other)
    {
        // Find all the tanks in an area around the shell and damage them.
        Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius, m_TankMask);

        for (int i = 0; i < colliders.Length; i++)
        {
            Rigidbody targetRigidbody = colliders[i].GetComponent <Rigidbody>();

            if (!targetRigidbody)
            {
                continue;
            }

            targetRigidbody.AddExplosionForce(m_ExplosionForce, transform.position, m_ExplosionRadius);

            TankHealth targetHealth = targetRigidbody.GetComponent <TankHealth>();

            if (!targetHealth)
            {
                continue;
            }

            float damage = CalculateDamage(targetRigidbody.position);

            targetHealth.TakeDamage(damage);
        }

        m_ExplosionParticles.transform.parent = null;
        m_ExplosionParticles.Play();
        m_ExplosionAudio.Play();
        Destroy(m_ExplosionParticles.gameObject, m_ExplosionParticles.duration);
        Destroy(gameObject);
    }
コード例 #8
0
    private void OnTriggerEnter(Collider other)
    {
        //Find all the tanks in the area around the shell and damage them.
        Collider[] colliders = Physics.OverlapSphere(transform.position, explosionRadius, tankMask);
        //Having it to check them
        for (int i = 0; i < colliders.Length; i++)
        {
            //Check the rigid body of the object
            Rigidbody targetRigidbody = colliders[i].GetComponent <Rigidbody>();
            //Has it found a rigid body
            if (!targetRigidbody)
            {
                continue;
            }
            // TODO: Add force to push tank
            //targetRigidbody.AddExplosionForce(explosionForce, transform.position, explosionRadius);
            // TODO: Begin to apply damage to the tank player script (in the tutorial has a script by itself for the health of the tank)
            TankHealth targetHealth = targetRigidbody.GetComponent <TankHealth>();
            //if(!targetHealth)
            //continue;
            // TODO: Create damage by seeing how far it is from the explosion.
            //float damage = CalculateDamage (targetRigidbody.position);
            //Updates the amount of health left to the player.
            targetHealth.DamageAmount(10);

            Debug.Log("hit has been his");
        }
        // TODO: Spawn the particle affect of the explosion
        explosionParticles.transform.parent = null;
        explosionParticles.Play();
        Destroy(explosionParticles.gameObject, explosionParticles.main.duration);
        // TODO: Play the audio file for the explosion.
        explosionAudio.Play();
    }
コード例 #9
0
    private void OnCollisionEnter(Collision collision)
    {
        if (!isAlive)
        {
            return;
        }


        isAlive = false;

        shellRenderer.enabled = false;

        explosionParticule.gameObject.SetActive(true);
        explosionParticule.Play(true);
        //Debug.Log("shell explode");


        //if (!isServer)
        //return;

        if (!danger || collision.gameObject.tag != "Player")
        {
            return;
        }

        TankHealth health = collision.gameObject.GetComponent <TankHealth>();

        if (health != null)
        {
            health.TakeDamage(10);
        }
    }
コード例 #10
0
 void Start()
 {
     movement   = GetComponent <TankMovement>();
     shooting   = GetComponent <TankShooting>();
     health     = GetComponent <TankHealth>();
     mainCamera = Camera.main;
 }
コード例 #11
0
    //When the shell hits something
    void OnCollisionEnter(Collision other)
    {
        //If the shell isn't live, leave
        if (!isLive)
        {
            return;
        }

        //The shell is going to explode and is no longer live
        isLive = false;

        //Hide the shell body
        shellRenderer.enabled = false;
        //Show the explosion particle effect
        explosionParticles.Play(true);

        //If the shell isn't lethal or it didn't hit a player, leave
        if (!canKill || other.gameObject.tag != "Player")
        {
            return;
        }

        //Get a reference to the hit object's Tank Health script and tell it to take a point of damage
        TankHealth health = other.gameObject.GetComponent <TankHealth> ();

        if (health != null)
        {
            health.TakeDamage(1);
        }
    }
コード例 #12
0
    private void OnTriggerEnter(Collider other)
    {
        if (active)
        {
            // Find all the tanks in an area around the fist and damage them.

            //Get all coliders in the radius of the exploding fist
            Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius, m_TankMask);

            foreach (var collider in colliders)
            {
                Rigidbody targetRigidBody = collider.GetComponent <Rigidbody>();
                if (targetRigidBody)
                {
                    targetRigidBody.AddExplosionForce(m_ExplosionForce, transform.position, m_ExplosionRadius);

                    TankHealth targetHealth = collider.GetComponent <TankHealth>();
                    if (targetHealth)
                    {
                        float damage = CalculateDamage(targetRigidBody.position);
                        targetHealth.TakeDamage(damage);
                    }
                }
            }

            m_ExplosionParticles.transform.parent = null;
            m_ExplosionParticles.Play();
            if (m_ExplosionAudio != null)
            {
                m_ExplosionAudio.Play();
            }
            Destroy(m_ExplosionParticles.gameObject, m_ExplosionParticles.main.duration);
            Destroy(gameObject);
        }
    }
コード例 #13
0
ファイル: MineController.cs プロジェクト: aulia14/GameMagang2
    private void OnTriggerEnter(Collider other)
    {
        Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius, m_TankMask);
        for (int i = 0; i < colliders.Length; i++)
        {
            Rigidbody targetRigidbody = colliders[i].GetComponent <Rigidbody>();
            if (!targetRigidbody)
            {
                continue;
            }
            targetRigidbody.AddExplosionForce(m_ExplosionForce, transform.position, m_ExplosionRadius);
            TankHealth targetHealth = targetRigidbody.GetComponent <TankHealth>();
            if (targetHealth && other.tag == "Enemy")
            {
                continue;
            }
            if (!targetHealth)
            {
                continue;
            }


            float damage = CalculateDamage(targetRigidbody.position);
            targetHealth.TakeDamage(damage);
        }
        Debug.Log("Kena");
        //ExplosionParticles.transform.parent = null;
        m_ExplosionParticles.Play();

        m_ExplosionAudio.Play();
        ParticleSystem.MainModule mainModule = m_ExplosionParticles.main;
        Destroy(m_ExplosionParticles.gameObject, mainModule.duration);
        Destroy(gameObject);
    }
コード例 #14
0
    private void OnTriggerEnter(Collider other)
    {
        // Find all the tanks in an area around the shell and damage them.
        foreach (Collider collider in Physics.OverlapSphere(transform.position, ExplosionRadius, TankMask))
        {
            Rigidbody rb = collider.GetComponent <Rigidbody>();
            if (!rb)
            {
                continue;
            }

            rb.AddExplosionForce(ExplosionForce, transform.position, ExplosionRadius);

            TankHealth th = collider.GetComponent <TankHealth>();
            if (!th)
            {
                continue;
            }

            float damage = CalculateDamage(rb.position);

            th.TakeDamage(damage);
        }

        ExplosionParticles.transform.parent = null;
        ExplosionParticles.Play();
        ExplosionAudio.Play();

        Destroy(ExplosionParticles.gameObject, ExplosionParticles.main.duration);
        Destroy(gameObject);
    }
コード例 #15
0
    // Start is called before the first frame update
    void Start()
    {
        if (gm == null)
        {
            gm = GetComponent <GameManage>();
        }

        if (Player == null)
        {
            Player = GameObject.FindGameObjectWithTag("Player");
        }

        if (MainCamera == null)
        {
            MainCamera = GameObject.FindGameObjectWithTag("MainCamera");
        }

        gm.currentGameState = GameState.GamePlaying;
        IsPlayerDead        = false;
        currentScore        = 0;
        startTime           = Time.time;
        playerTankHealth    = Player.GetComponent <TankHealth>();

        ShowPlayingUI();
    }
コード例 #16
0
ファイル: TankManager.cs プロジェクト: Fmccline/TankFriends
    public void Setup()
    {
        m_Movement = m_Instance.GetComponent <TankMovement>();
        m_Shooting = m_Instance.GetComponent <TankShooting>();
        m_Health   = m_Instance.GetComponent <TankHealth>();

        m_TankInput            = TankInputFactory.MakeTankWithInput(m_InputType);
        m_Movement.m_TankInput = m_TankInput;
        m_Shooting.m_TankInput = m_TankInput;

        m_TankScore        = new Score(m_PlayerNumber);
        m_Shooting.m_Score = m_TankScore;
        m_Health.m_Score   = m_TankScore;

        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;
        }
        m_CurrentColor = m_PlayerColor;
    }
コード例 #17
0
    void OnTriggerEnter(Collider other)
    {
        // public GameObject m_Instance;
        // TankHealth th= m_Instance.GetComponent<TankHealth>();

        //th.m_CurrentHealth += 15;
        Rigidbody targetRigidbody = other.GetComponent <Rigidbody>();
        //Debug.Log(th.m_CurrentHealth);
        int heal = 25;

        if (other.name == "CompleteTank(Clone)")
        {
            TankHealth targetHealth = targetRigidbody.GetComponent <TankHealth>();
            if (targetHealth.getHealth() < 100)
            {
                Debug.Log("lol");
                Destroy(gameObject);
                targetHealth.getPottion(heal);
            }
        }
        // Debug.Log(targetHealth.);

        // Debug.Log(th.m_Slider.value);
        // other.tag.g
    }
コード例 #18
0
    private void OnTriggerEnter(Collider other)
    {
        Collider[] cols = Physics.OverlapSphere(transform.position, m_ExplosionRadius, m_TankMask);
        for (int i = 0; i < cols.Length; ++i)
        {
            Rigidbody targetR = cols[i].GetComponent <Rigidbody>();
            if (!targetR)
            {
                continue;
            }
            targetR.AddExplosionForce(m_ExplosionForce, transform.position, m_ExplosionRadius);

            TankHealth targetH = targetR.GetComponent <TankHealth>();
            if (!targetH)
            {
                continue;
            }
            targetH.TakeDamage(CalculateDamage(targetR.position));
        }

        m_ExplosionParticles.transform.parent = null;
        m_ExplosionParticles.Play();
        m_ExplosionAudio.Play();

        Destroy(m_ExplosionParticles.gameObject, m_ExplosionParticles.duration);
        Destroy(gameObject);
    }
コード例 #19
0
ファイル: ShellExplosion.cs プロジェクト: BenjiBoy926/Tanks
    protected virtual void OnTriggerEnter(Collider other)
    {
        Collider[] tankColliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius, m_TankMask);

        // Damage each of the tanks in the tanks hit
        foreach (Collider tank in tankColliders)
        {
            // Add an explosion force to the tank's rigidbody
            Rigidbody tankRigidbody = tank.GetComponent <Rigidbody>();
            if (!tankRigidbody)
            {
                continue;
            }
            tankRigidbody.AddExplosionForce(m_ExplosionForce, transform.position, m_ExplosionRadius);

            // Reduce health of the tank health script
            TankHealth tankHealth = tank.GetComponent <TankHealth>();
            if (!tankHealth)
            {
                continue;
            }
            tankHealth.TakeDamage(CalculateDamage(tankRigidbody.position));
        }

        // Unparent the particles from the shell.
        m_ExplosionParticles.transform.parent = null;

        // Play the particle system.
        m_ExplosionParticles.Play();
        m_ExplosionAudio.Play();

        Destroy(m_ExplosionParticles.gameObject, m_ExplosionParticles.main.duration);
    }
コード例 #20
0
    private void FindAllTanksAroundTheShellAndDamgeThem()
    {
        Collider[] collidersArray = Physics.OverlapSphere(transform.position, explosionRadius);

        for (int i = 0; i < collidersArray.Length; i++)
        {
            if (collidersArray[i].tag != ("Player") && collidersArray[i].tag != ("Enemy"))
            {
                continue;
            }
            Rigidbody targetRigidBody = collidersArray[i].GetComponent <Rigidbody>();

            if (!targetRigidBody)
            {
                continue;
            }

            targetRigidBody.AddExplosionForce(explosionForce, transform.position, explosionRadius);

            TankHealth targetHealth = targetRigidBody.GetComponent <TankHealth>();

            if (!targetHealth)
            {
                continue;
            }

            float damage = CalculateDamage(targetRigidBody.position);

            targetHealth.TakeDamage(damage);
        }

        PlayExplosionEffectAndSound();

        DestroyTheShellAndExplosionParticles();
    }
コード例 #21
0
    void Update()
    {
        if (!player || !scoreManager)
        {
            player       = GameObject.FindGameObjectWithTag("Allies");
            playerHealth = player.GetComponent <TankHealth>();
            scoreObject  = GameObject.FindGameObjectWithTag("ScoreManager");
            scoreManager = scoreObject.GetComponent <Scores>();
        }

        text.text = "Score: " + score;
        if (playerHealth.empty())
        {
            if (!scoreSent)
            {
                scoreManager.addScore(score);
                scoreSent = true;
            }
            if (isWaiting)
            {
                StartCoroutine(Wait());
            }
            if (!isWaiting)
            {
                SceneManager.LoadScene("MainMenu");
            }
        }
    }
コード例 #22
0
    private void OnTriggerEnter(Collider other)
    {
        Collider[] colliders = Physics.OverlapSphere(transform.position, shellExplosionRidus, tankMask);
        for (int i = 0; i < colliders.Length; i++)
        {
            Rigidbody collideTarget = colliders[i].GetComponent <Rigidbody>();
            if (!collideTarget)
            {
                continue;
            }

            for (int j = 0; j < colliders.Length; j++)
            {
                TankHealth tankHealth = colliders[j].GetComponent <TankHealth>();
                if (!tankHealth)
                {
                    continue;
                }
                float damage = DamageCounter(colliders[j].GetComponent <Rigidbody>().position);
                tankHealth.HealthDown(damage);
            }
            ShellExplode();
        }
        //throw new NotImplementedException();
    }
コード例 #23
0
ファイル: Shell.cs プロジェクト: OliverParkes/Oliver-Tanks
    private void OnCollisionEnter(Collision other)
    {
        Rigidbody targetRididbody = other.gameObject.GetComponent <Rigidbody>();

        if (targetRididbody != null)
        {
            targetRididbody.AddExplosionForce(ExplosionForce, transform.position, ExplosionRadius);

            TankHealth TargetHealth = targetRididbody.GetComponent <TankHealth>();

            if (TargetHealth != null)
            {
                float damage = CalculateDamage(targetRididbody.position);

                TargetHealth.TakeDamage(damage);
            }
        }


        m_ExplosionParticles.transform.parent = null;

        m_ExplosionParticles.Play();
        Destroy(m_ExplosionParticles.gameObject, m_ExplosionParticles.main.duration);

        Destroy(gameObject);
    }
コード例 #24
0
ファイル: Shell.cs プロジェクト: Saltered8/Big-Dome
    private void OnCollisionEnter(Collision other)
    {
        // find the rigidbody of the collision object
        Rigidbody targetRigidbody = other.gameObject.GetComponent <Rigidbody>();

        // only tanks will have rigidbody scripts
        if (targetRigidbody != null)
        {
            // Add an explosion force
            targetRigidbody.AddExplosionForce(m_ExplosionForce,
                                              transform.position, m_ExplosionRadius);
            // find the TankHealth script associated with the rigidbody
            TankHealth targetHealth = targetRigidbody.GetComponent <TankHealth>();
            if (targetHealth != null)
            {
                // Calculate the amount of damage the target should take
                // based on it's distance from the shell.
                float damage = CalculateDamage(targetRigidbody.position);
                // Deal this damage to the tank
                targetHealth.TakeDamage(damage);
            }
        }

        // Unparent the particles from the shell
        m_ExplosionParticles.transform.parent = null;

        // Play the particle system
        m_ExplosionParticles.Play();

        // Once the particles have finished, destroy the gameObject they are on
        Destroy(m_ExplosionParticles.gameObject, m_ExplosionParticles.main.duration);

        // Destroy the shell
        Destroy(gameObject);
    }
コード例 #25
0
    public void Setup()
    {
        m_PlayerName = PlayerPrefs.GetString("Player" + m_PlayerNumber);
        //Input
        m_FireButton       = "Fire" + m_PlayerNumber;
        m_MovementAxisName = "Vertical" + m_PlayerNumber;
        m_TurnAxisName     = "Horizontal" + m_PlayerNumber;
        m_Skill            = "Skill" + m_PlayerNumber;

        m_TankInfo = m_Instance.GetComponent <TankInfo>();
        if (!m_TankInfo)
        {
            return;
        }
        m_Movement         = m_TankInfo.tankMovement;
        m_Shooting         = m_TankInfo.tankShooting;
        m_CanvasGameObject = m_TankInfo.tankCanvas;
        m_TankEffects      = m_TankInfo.tankEffects;
        m_TankHealth       = m_TankInfo.tankHealth;
        m_SkillBase        = m_TankInfo.skill;
        m_TankInfo.id      = m_PlayerNumber;


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

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

        for (int i = 0; i < renderers.Length; i++)
        {
            renderers[i].material.color = m_PlayerColor;
        }
    }
コード例 #26
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_Aim    = m_Instance.GetComponent <TankAim>();
        m_Fire   = m_Instance.GetComponent <TankFire>();
        m_Health = m_Instance.GetComponent <TankHealth>();

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

        // Set the player numbers to be consistent across the scripts.
        m_Aim.m_PlayerNumber    = m_PlayerNumber;
        m_Fire.m_PlayerNumber   = m_PlayerNumber;
        m_Health.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.
        SpriteRenderer[] renderers = m_Instance.GetComponentsInChildren <SpriteRenderer>();

        // 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].color = m_PlayerColor;
        }
    }
コード例 #27
0
ファイル: TankManager.cs プロジェクト: IgorCH/md
    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;
    }
コード例 #28
0
 private void Awake()
 {
     nm      = GetComponent <NavMeshAgent>();
     counter = 0;
     tank    = GetComponent <TankHealth>();
     //setDestination();
 }
コード例 #29
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;
    }
コード例 #30
0
    void Spawn()
    {
        GameObject spawnedEnemy = pool.GetObject();

        enemyAI = spawnedEnemy.GetComponent <AIManager>();

        enemyHealth = spawnedEnemy.GetComponent <TankHealth>();

        for (int i = 0; i < waypoints.Count; i++)
        {
            enemyAI.waypoints[i] = waypoints[i];
        }

        enemyHealth.health = wave.tankHealth;

        enemyHealth.moneyTracker = moneyTracker;

        spawnedEnemy.transform.position = transform.position;

        spawnedEnemy.transform.rotation = transform.rotation;

        spawnedEnemy.SetActive(true);

        enemyAI.setDestination();
    }
コード例 #31
0
 // Start is called before the first frame update
 void Start()
 {
     // get components for each variable for inspector
     mover   = GetComponent <TankMover>();
     shooter = GetComponent <TankShooter>();
     health  = GetComponent <TankHealth>();
 }
コード例 #32
0
 public ExplodeCommand(TankController controller, Rigidbody rigidBody, TankHealth health, GameObject explosionPrefab)
     : base(controller)
 {
     m_IsBlocking = true;
     m_RigidBody = rigidBody;
     m_Health = health;
     m_ExplosionPrefab = explosionPrefab;
 }
コード例 #33
0
ファイル: GUI_Text.cs プロジェクト: CloneCommando/Portfolio
 void getValues()
 {
     numEnemies = GameObject.Find("EnemySquad1").GetComponent<Controller>().numberOfFlockers;
     numEnemies += GameObject.Find("EnemySquad2").GetComponent<Controller>().numberOfFlockers;
     numEnemies += GameObject.Find("EnemySquad3").GetComponent<Controller>().numberOfFlockers;
     allyHP = GameObject.Find("SovietTank(Clone)").GetComponent<TankHealth>();
     isUpdated = true;
 }
コード例 #34
0
ファイル: GUI_Text.cs プロジェクト: CloneCommando/Portfolio
 // Use this for initialization
 void Start()
 {
     playerHP = GameObject.Find("Player").GetComponent<TankHealth>();
     healthText = GameObject.Find("GUI HP").GetComponent<GUIText>();
     allyText = GameObject.Find("GUI allyHP").GetComponent<GUIText>();
     enemiesText = GameObject.Find("GUI numEnemies").GetComponent<GUIText>();
     myColor = Color.blue;
     healthText.material.color = myColor;
     enemiesText.material.color = myColor;
     allyText.material.color = myColor;
 }
コード例 #35
0
    void OnCollisionEnter(Collision collision)
    {
        if(collision.gameObject.tag == "Allies"){
            playerHealth = collision.collider.GetComponent<TankHealth>();
            playerHealth.addHealth(addAmountOfHealth);

            audio.PlayOneShot(sound);
            GetComponent<BoxCollider>().isTrigger = true;
            GetComponentInChildren<Light>().color = new Color(127,255,0);
            GetComponentInChildren<Light>().intensity = 0.1f;
            Destroy(gameObject, sound.length);
        }
    }
コード例 #36
0
    /* Shooting Damage */
    void OnCollisionEnter(Collision collision) {

        //Tank
        if(collision.gameObject.tag == "Tank"){
           tankHealth = collision.gameObject.GetComponent<TankHealth>();

           if(tankHealth != null)
              tankHealth.TakingDamage(shootingDamage);
        }

        //TTurret
        if(collision.collider.tag == "TTurret") {
           Transform turret = collision.collider.transform;

           if(turret)
              turret.GetComponent<Tank_AutoTurret>().TakingDamage(shootingDamage);
        }

        Destroy(gameObject);
    }
コード例 #37
0
    private void HandleHealthbar()
    {
        if(player == null){
            player = GameObject.FindGameObjectWithTag("Allies");
            tankHealth = player.GetComponent<TankHealth>();
            maxHealth = tankHealth.maxHealth;
        }
        healthText.text = "Health: " + tankHealth.getTankHealth();

        currentValue = Map(tankHealth.getTankHealth(), 0, maxHealth, 0, 1);

        visualHealth.fillAmount = Mathf.Lerp(visualHealth.fillAmount, currentValue, Time.deltaTime*healthSpeed);

        if (tankHealth.getTankHealth() > maxHealth / 2) {
            visualHealth.color = new Color32((byte)Map(tankHealth.getTankHealth(), maxHealth / 2, maxHealth, 255, 0), 255, 0, 255);
        }
        else {
            visualHealth.color = new Color32(255, (byte)Map(tankHealth.getTankHealth(), 0, maxHealth / 2, 0, 255), 0, 255);
        }
    }
コード例 #38
0
    void Update()
    {
        if(!player || !scoreManager){
            player = GameObject.FindGameObjectWithTag("Allies");
            playerHealth = player.GetComponent<TankHealth>();
            scoreObject = GameObject.FindGameObjectWithTag("ScoreManager");
            scoreManager = scoreObject.GetComponent<Scores>();
        }

        text.text = "Score: " + score;
        if(playerHealth.empty()){
            if(!scoreSent){
                scoreManager.addScore(score);
                scoreSent = true;
            }
            if(isWaiting)
                StartCoroutine(Wait());
            if(!isWaiting)
                SceneManager.LoadScene("MainMenu");
        }
    }
コード例 #39
0
    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;
    }
コード例 #40
0
    void Update()
    {
        if(isSinking)
        {
            transform.Translate (-Vector3.up * sinkSpeed * Time.deltaTime);
        }
        if(!canvas){
            canvas = GameObject.FindGameObjectWithTag("Canvas").GetComponent<Transform>();
            scoreManager = canvas.Find("Score").GetComponent<ScoreController>();
        }

        if(!AIhealth.empty()){

            if(timer>0){
                timer -= Time.deltaTime;
            }

            if(!player){
                player = GameObject.FindGameObjectWithTag("Allies").transform;
                playerHealth = player.GetComponent <TankHealth> ();
            }

            //if(playerHealth.getTankHealth() > 0 && AIhealth.getTankHealth() > 0){
            if(!stop && AIhealth.getTankHealth() > 0){
                //nav.Resume();
                nav.SetDestination (player.position);
            }else if(!stop){

                nav.enabled = false;
                //nav.Stop();
            }
        }else {
            if(!exploded)
                Explode();
            StartSinking();
        }
    }
コード例 #41
0
 void Start()
 {
     leftTrack = GameObject.Find(gameObject.name + "/Lefttrack").GetComponent<MoveTrack>();
     rightTrack = GameObject.Find(gameObject.name + "/Righttrack").GetComponent<MoveTrack>();
     tankHealth = GetComponent<TankHealth>();
     distToGround = GetComponent<Collider>().bounds.extents.y;
     gameObject.tag = "Allies";
     engineSource = GetComponent<AudioSource>();
 }
コード例 #42
0
ファイル: Armor.cs プロジェクト: Dimitur-Matev/Game-of-Tanks
 void Start()
 {
     tankHealthManager = GetComponent<TankHealth>();
 }
コード例 #43
0
 void Awake()
 {
     playerHealth = player.GetComponentInParent<TankHealth>();
 }
コード例 #44
0
 void Awake()
 {
     AIhealth = GetComponentInParent <TankHealth> ();
     firePoint = GetComponentInChildren<Transform>();
 }
コード例 #45
0
ファイル: TankController.cs プロジェクト: RostDetal/Tanks
	private void Initialize()
	{
		currentWeapon = 0;
        tankHealth = transform.FindChild("MainBody").GetComponent<TankHealth>();
		ResetCooldown ();
	}
コード例 #46
0
 void Awake()
 {
     tankHealth = GetComponentInParent<TankHealth>();
     maxHealth = tankHealth.maxHealth;
     player = GameObject.FindGameObjectWithTag("Allies");
 }
コード例 #47
0
ファイル: TankShooting.cs プロジェクト: kaancfidan/TankBrawl
 private void Awake()
 {
     m_Controller = GetComponent<TankController>();
     m_RigidBody = GetComponent<Rigidbody>();
     m_Health = GetComponent<TankHealth>();
 }
コード例 #48
0
 void Awake()
 {
     AIhealth = GetComponent <TankHealth> ();
     nav = GetComponent <NavMeshAgent> ();
     source = GetComponent<AudioSource>();
 }
コード例 #49
0
    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;
        }
    }
コード例 #50
0
 void Awake()
 {
     AIhealth = GetComponentInParent <TankHealth> ();
 }