Пример #1
0
    private void Awake()
    {
        // Get collider sizes
        ColliderSize();

        // Load prefab
        enemyMushroom = Resources.Load <EnemyMushroom>("MushObstacle");

        // Simulating segment ID
        segmentNumber = SegmentInfo.AddSegment();

        spriteRenderer = GetComponent <SpriteRenderer>();

        // If it's a first segment in centipede - make it main(head)
        if (isFirst)
        {
            spriteRenderer.sprite = Resources.Load <Sprite>("EnemyHead2");
        }
        else
        {
            spriteRenderer.sprite = Resources.Load <Sprite>("EnemyHead4");
        }

        GetCameraSizes();

        position  = new Vector3(0, maxY - 1);
        direction = new Vector3(0.1f, 0);
    }
Пример #2
0
    public override void ReceiveDamage()
    {
        Vector3       position         = transform.position;
        EnemyMushroom newEnemyMushroom = Instantiate(enemyMushroom, position, enemyMushroom.transform.rotation);

        Player.score += (Player.wave * 5);
        Player.livingSegments--;
        base.ReceiveDamage();
    }
Пример #3
0
 // Random generating mushrooms
 private void GenerateMushrooms()
 {
     for (int i = (int)minX + 2; i < (int)maxX - 2; i++)
     {
         for (int j = (int)maxY - 10; j > (int)minY + 10; j--)
         {
             int chance = Random.Range(0, 100);
             Debug.Log(chance);
             if (chance >= 97)
             {
                 EnemyMushroom newEnemyMushroom = Instantiate(enemyMushroom, new Vector3(i, j), enemyMushroom.transform.rotation);
             }
         }
     }
     Debug.Log((int)minY + "     " + (int)maxY);
 }
Пример #4
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        Unit unit = collider.GetComponent <Unit>();

        if (unit is Player)
        {
            unit.ReceiveDamage();
        }
        if (unit is EnemyMushroom)
        {
            EnemyMushroom EnterMush = new EnemyMushroom();
            //EnterMush.
            Vector3 pos = transform.position;
            pos.x += 0.5f;
            pos.y += 0.5f;
            transform.position = pos;
        }
    }
Пример #5
0
    public override void ReceiveDamage()
    {
        try
        {
            if (SegmentInfo.centipede[segmentNumber + 1] != null)
            {
                EnemyHead CurrentSegment = (EnemyHead)SegmentInfo.centipede[segmentNumber + 1];
                CurrentSegment.spriteRenderer.sprite = Resources.Load <Sprite>("EnemyHead2");
            }
        }
        catch (Exception exception)
        {
            Debug.Log(exception.ToString());
        }

        Vector3       position         = transform.position;
        EnemyMushroom newEnemyMushroom = Instantiate(enemyMushroom, position, enemyMushroom.transform.rotation);

        Player.score += (Player.wave * 5);
        Player.livingSegments--;
        base.ReceiveDamage();
    }
Пример #6
0
    private void Awake()
    {
        enemyMushroom = Resources.Load <EnemyMushroom>("MushObstacle");

        spriteRenderer = GetComponent <SpriteRenderer>();

        if (isFirst)
        {
            spriteRenderer.sprite = Resources.Load <Sprite>("EnemyHead2");
        }
        else
        {
            spriteRenderer.sprite = Resources.Load <Sprite>("EnemyHead4");
        }

        GetCameraSizes();

        gridPosition      = new Vector2Int(0, (int)maxY - 1);
        gridMoveTimerMax  = 0.1f;
        gridMoveTimer     = gridMoveTimerMax;
        gridMoveDirection = new Vector2Int(1, 0);
    }
Пример #7
0
    private void Awake()
    {
        // Create class object for creating arraylist with Cintepede segments info
        SegmentInfo segInfo = new SegmentInfo();


        // Timer for generating segments
        timerMax     = 0.8f;
        timer        = timerMax;
        spriteRender = GetComponent <SpriteRenderer>();

        // Find length from center of player's ship to border
        boxCollider2D = GetComponent <BoxCollider2D>();
        Vector3 pos = transform.position;

        leftradius  = pos.x - boxCollider2D.bounds.min.x;
        upperradius = pos.y - boxCollider2D.bounds.min.y;

        // Loading prefabs
        enemyMushroom = Resources.Load <EnemyMushroom>("MushObstacle");
        enemyHead     = Resources.Load <EnemyHead>("EnemyHead");
        bullet        = Resources.Load <Bullet>("Bullet");
    }
Пример #8
0
 // Use this for initialization
 void Start()
 {
     em             = GetComponentInParent <EnemyMushroom>();
     EnemyDethEven += em.Deth;
 }