public void InstantiateSlashPrefab()
    {
        BulletObject slash       = m_SlashPool.Pop(transform.position + (m_SpriteRenderer.flipX ? Vector3.left * 0.5f : Vector3.right * 0.5f));
        PlayerSlash  playerSlash = slash.transform.GetComponent <PlayerSlash>();

        playerSlash.speed = Mathf.Abs(playerSlash.speed) * (m_SpriteRenderer.flipX ? -1 : 1);
    }
    void Start()
    {
        // Destroy duplicate gameController
        gameControllers = FindObjectsOfType <GameController>();
        if (gameControllers.Length == 1)
        {
            gameController = FindObjectOfType <GameController>();
        }
        else if (gameControllers[0].initializationTime > gameControllers[1].initializationTime)
        {
            Destroy(gameControllers[0].gameObject);
            gameController = gameControllers[1];
        }
        else
        {
            Destroy(gameControllers[1].gameObject);
            gameController = gameControllers[0];
        }

        Debug.Log("The Player is starting");
        Time.timeScale      = movementSpeed;
        Time.fixedDeltaTime = movementSpeed * 0.2f;

        // Apply loaded save game stats
        LevelUpPlayer();

        currentHealth = maxHealth;
        currentAmmo   = maxAmmo;

        rigidBody.freezeRotation = true;
        updatePosition();

        sword = GetComponentInChildren <PlayerSlash>();
    }
 protected new void OnTriggerStay2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         if (canHurtPlayer)
         {
             PlayerController player = collision.transform.GetComponent <PlayerController>();
             player.setCurrentHealth(player.getCurrentHealth() - (int)attackValue);
             canHurtPlayer = false;
             StartCoroutine("CanHurtAgain");
         }
         else
         {
             PlayerSlash sword = collision.transform.GetComponent <PlayerSlash>();
             if (sword != null)
             {
                 if ((sword.isSlashing) && (canGetSlashed))
                 {
                     curHitPoints -= sword.attackValue;
                     canGetSlashed = false;
                     StartCoroutine("NextSlashDamageDelay", sword);
                 }
             }
         }
     }
 }
示例#4
0
    protected void OnTriggerStay2D(Collider2D collision)
    {
        PlayerSlash slash = collision.transform.GetComponent <PlayerSlash>();

        if (slash != null)
        {
            if ((slash.isSlashing) && canGetSlashed)
            {
                curHitPoints -= slash.attackValue;
                canGetSlashed = false;
                StartCoroutine("NextSlashDamageDelay", slash);
            }
        }
    }
示例#5
0
    protected new void OnTriggerEnter2D(Collider2D collision)
    {
        PlayerBullet bullet = collision.transform.GetComponent <PlayerBullet>();

        if (bullet != null)
        {
            if (!isIndestructible)
            {
                this.curHitPoints -= bullet.attackValue;
                Destroy(collision.gameObject);
            }
        }
        else
        {
            PlayerSlash sword = collision.transform.GetComponent <PlayerSlash>();
            if (sword != null)
            {
                if (!isIndestructible)                // && (sword.isSlashing))
                {
                    //Debug.Log("PROJECTILE DESTROYED BY SWORD!");
                    Destroy(this.gameObject);
                }
            }
            else
            {
                PlayerController player = collision.transform.GetComponent <PlayerController>();
                if (player != null)
                {
                    // TODO: Damage player?
                    Destroy(this.gameObject);
                }
                else
                {
                    if (collision.transform.tag == "Wall")
                    {
                        //Debug.Log("Enemy projectile came in contact with wall");
                        Destroy(this.gameObject);
                    }
                    else if (collision.CompareTag("Door"))
                    {
                        Destroy(this.gameObject);
                    }
                    else
                    {
                        // Debug.Log("Enemy projectile hasn't collided with any object of note.");
                    }
                }
            }
        }
    }
示例#6
0
 void Start()
 {
     inputManager = GameObject.Find("GameManager").GetComponent <InputManager>();
     inputManager.Start();
     ground = LayerMask.NameToLayer("ground");
     Debug.Log(LayerMask.LayerToName(ground));
     PlayerState.Instance.Init();
     PlayerState.Instance.playerActionsFreezed = false;
     PlayerState.Instance.stingDmgCheckPoint   = transform.position;
     curtainAnimator  = GameObject.Find("curtain").GetComponent <Animator>();
     animator         = GetComponent <Animator>();
     rigidBody        = GetComponent <Rigidbody2D>();
     coldDownTimes[0] = 0; //dash
     coldDownTimes[1] = 0; //bullet
     coldDownTimes[2] = 0; //slash
     coldDownTimes[3] = 0; //defend
     playerDefend     = defendObject.GetComponent <PlayerDefend>();
     playerSlash      = slashObject.GetComponent <PlayerSlash>();
 }
示例#7
0
    protected IEnumerator NextSlashDamageDelay(PlayerSlash slash)
    {
        yield return(new WaitForSeconds(slash.slashDurationRemaining));

        canGetSlashed = true;
    }