Exemple #1
0
    protected override void HitCallback(PlayerHit player)
    {
        int    splitIn          = 2;
        Sprite smallSplitSprite = Resources.Load <Sprite>("SinglePlayer/Enemies/Splitter/SSplitter");
        Object enemyPrefab      = Resources.Load("Prefabs/Enemy1");

        for (int i = 0; i < splitIn; i++)
        {
            GameObject split = GameObject.Instantiate(enemyPrefab) as GameObject;
            split.transform.position = this.transform.position;
            split.name = splitIDs[i] + " SmallSplitter";
            split.GetComponent <SpriteRenderer>().sprite = smallSplitSprite;
            EnemyBase enemyBase = split.GetComponent <EnemyBase>();
            enemyBase.Init();
            enemyBase.CorrectSprite();
            enemyBase.DoStun = false;
            enemyBase.spawnInvulnerability = 0.1f;
            enemyBase.faceRight            = i == 0 || i % 2 == 0; //alternating facing left and right
        }



        player.BounceUp(player.gameObject);
        OnDeath(player);
    }
Exemple #2
0
 protected override void HitCallback(PlayerHit player)
 {
     player.BounceUp(player.gameObject);
     if (!_spikes)
     {
         OnDeath(player);
     }
 }
Exemple #3
0
 protected void OnDeath(PlayerHit player)
 {
     if (player)
     {
         player.BounceUp(gameObject);
     }
     DoSplat();
     GameObject.Destroy(this.gameObject);
 }
Exemple #4
0
 private void OnHit(PlayerHit player)
 {
     if (_stunnedTimer > 0 || InstaKill || !DoStun)
     {
         HitCallback(player);
     }
     else
     {
         player.BounceUp(player.gameObject);
         _stunnedTimer = _stunnedTime;
         //START STUNNED ANIMATION
         _rigid.velocity = new Vector2(transform.position.x < player.transform.position.x ? -1 : 1, 1) * BounceStrength;
         StartStunAnimation();
     }
 }
Exemple #5
0
    protected override void HitCallback(PlayerHit player)
    {
        player.BounceUp(player.gameObject);
        if (hasFallen)
        {
            OnDeath(player);
        }
        else
        {
            hasFallen = true;

            RaycastHit2D hit;

            if (CheckGrounded(out hit))
            {
                Debug.Log("started falling");
                float spriteYSize = 0.48f;  //min falling distance (1.5 blocks so it will in all cases be pushed out the bottom by physics)
                remainingFallingDistance = spriteYSize;
                //TODO sprite layer BEHIND level blocks
                System.Array.ForEach(GetComponentsInChildren <Collider2D>(), x => x.isTrigger = true);
            }
        }
    }
Exemple #6
0
 protected virtual void HitCallback(PlayerHit player)
 {
     OnDeath(player);
     player.BounceUp(player.gameObject);
     //dead
 }