Esempio n. 1
0
 public PlayerInfo(GameObject Player, _CharacterController PlayerController, Transform PlayerSpawnPoint, int Score)
 {
     player           = Player;
     playerController = PlayerController;
     playerSpawnPoint = PlayerSpawnPoint;
     score            = Score;
 }
Esempio n. 2
0
 protected override void GrabWeapon(_CharacterController player)
 {
     isGrabbed            = true;
     rb.isKinematic       = true;
     transform.parent     = hand.transform;
     transform.position   = hand.transform.position;
     coll.enabled         = false;
     player.currentWeapon = GetComponent <Key>();
 }
Esempio n. 3
0
 protected virtual void DamageDealer(_CharacterController playerHit)
 {
     // check damage type and enemy resistance
     playerHit.currentLife -= damage;
     if (playerHit.currentLife <= 0)
     {
         playerHit.currentLife = 0;
     }
     GMController.instance.UI.UpdateLifeUI(playerHit.playerNumber);                               // update life on UI
     GMController.instance.LowerTensionCheck(GMController.instance.tensionStats.playerHitPoints); // sub tension
 }
Esempio n. 4
0
        // Use this for initialization
        protected override void Awake()
        {
            base.Awake();
            inactiveState = (State)Resources.Load("Inactive");
            // navMeshAgent = GetComponent<NavMeshAgent>();

            lastActiveState = currentState;

            m_CharacterController = GetComponent <_CharacterController>();

            gameStartState = (State)Resources.Load("StartState");
            defeatedState  = (State)Resources.Load("Defeated");
        }
Esempio n. 5
0
 public virtual void GrabAndDestroy(_CharacterController player)
 {
     // Grab sound
     source.PlayOneShot(grabSound, grabVolume);
     collTrigger.enabled = false;
     // Destroy the first
     player.DestroyCurrentWeapon();
     // get the second
     if (hand.transform.childCount <= 1)// (need to check condition)
     {
         GrabWeapon(player);
     }
 }
        public void DamagePlayer(Collider2D hit)
        {
            _CharacterController playerHit = hit.GetComponent <_CharacterController>();

            if (!playerHit.isInDash)
            {
                playerHit.currentLife -= m_EnemyStats.attackValue;
                if (playerHit.currentLife <= 0)
                {
                    playerHit.currentLife = 0;
                }
                GMController.instance.UI.UpdateLifeUI(playerHit.playerNumber);                               // update life on UI
                GMController.instance.LowerTensionCheck(GMController.instance.tensionStats.playerHitPoints); // sub tension
            }
        }
Esempio n. 7
0
    protected void EmissionHandler()
    {
        if (bullets == null || bullets.Length < thisParticle.main.maxParticles)
        {
            bullets = new ParticleSystem.Particle[thisParticle.main.maxParticles];
        }

        int numParticlesAlive = thisParticle.GetParticles(bullets);

        // cast ray from all the particles that are alive ti register hits
        for (int i = 0; i < numParticlesAlive; i++)
        {
            RaycastHit2D hit = Physics2D.Raycast(bullets[i].position, bullets[i].velocity.normalized, owner.m_EnemyStats.bulletRayLenght, owner.m_EnemyStats.hitMask);
            Debug.DrawRay(bullets[i].position, bullets[i].velocity.normalized, Color.blue);
            if (hit)
            {
                if (hit.transform.CompareTag("Player_1"))
                {
                    _CharacterController playerHit = hit.transform.GetComponent <_CharacterController>();
                    if (!playerHit.isInDash)// deal damage only if the player is not dashing
                    {
                        bullets[i].remainingLifetime = 0;
                        DamageDealer(playerHit);
                    }
                }
                else if (canBounce)
                {
                    CheckBulletLife(hit, i);

                    // bounce here
                    Vector2 hitNorm = hit.normal;
                    Vector2 newDir  = Vector2.Reflect(bullets[i].velocity, hitNorm);
                    bullets[i].velocity = newDir;
                }
                else
                {
                    bullets[i].remainingLifetime = 0;
                }
            }
        }
        // Apply the particle changes to the particle system
        thisParticle.SetParticles(bullets, numParticlesAlive);
    }
Esempio n. 8
0
    protected virtual void GrabWeapon(_CharacterController player)
    {
        isGrabbed          = true;
        rb.isKinematic     = true;
        rb.simulated       = false;
        transform.parent   = hand.transform;
        transform.position = hand.transform.position;

        player.currentWeapon = GetComponent <Weapon3D>();
        if (bullet != null)
        {
            bullet.membership       = weaponOwnership;
            bullet.transform.parent = null;
        }
        if (!isReward)
        {
            currentSpawn.SetCurrentWeaponToNull();
            currentSpawn.ResetTimer();
        }
    }
Esempio n. 9
0
 public void UseStation(_CharacterController player)
 {
     if (avaible && GMController.instance.playerInfo[player.playerNumber].Score >= price)
     {
         if (player.currentLife < player.m_CharStats.life)
         {
             healAmmount         = healAmountPercentage * player.m_CharStats.life / 100;
             player.currentLife += healAmountPercentage;
             if (player.currentLife > player.m_CharStats.life)
             {
                 player.currentLife = player.m_CharStats.life;
             }
             Debug.Log(healAmmount + "  " + player.currentLife);
             GMController.instance.playerInfo[player.playerNumber].Score -= price; // subtract payment from score
             GMController.instance.UI.UpdateScoreUI(player.playerNumber);          // update score on UI
             GMController.instance.UI.UpdateLifeUI(player.playerNumber);           // update life on UI
             Debug.Log("cured");
         }
         timer   = coolDown;
         avaible = false;
     }
 }
    public void Explosion(Vector2 position)
    {
        // emit particle
        transform.position = position;
        thisParticle.Emit(Random.Range(min, max));

        // check collision with players
        Collider2D[] colliders = Physics2D.OverlapCircleAll(position, thisParticle.shape.radius, explosionMask);
        for (int i = 0; i < colliders.Length; i++)
        {
            _CharacterController playerHit = colliders[i].GetComponent <_CharacterController>();
            if (!playerHit.isInDash) // deal damage only if the player is not dashing
            {
                playerHit.currentLife -= damage;
                if (playerHit.currentLife <= 0)
                {
                    playerHit.currentLife = 0;
                }
                GMController.instance.UI.UpdateLifeUI(playerHit.playerNumber);                               // update life on UI
                GMController.instance.LowerTensionCheck(GMController.instance.tensionStats.playerHitPoints); // sub tension
            }
        }
    }