Пример #1
0
    // Use this for initialization
    void Start()
    {
        rb     = gameObject.GetComponent <Rigidbody2D>();
        mybomb = Instantiate(bomb, transform.position, Quaternion.identity);
        BombControl bc = mybomb.GetComponent <BombControl>();

        bc.holder = gameObject;
    }
Пример #2
0
    private IEnumerator StartSequence()
    {
        OutlineControl outline = GetComponentInChildren<OutlineControl>();
        if (outline != null) outline.Trigger();

        yield return new WaitForSeconds(0.25f);

        BombControl bomb = transform.parent.GetComponentInChildren<BombControl>();
        if (bomb != null) bomb.Trigger();
    }
Пример #3
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetButton("Interact"))
     {
         interacting     = true;
         interactCharge += 0.01f;
         rb.velocity     = new Vector2(0, 0);
     }
     if (Input.GetButtonUp("Interact"))
     {
         interacting    = false;
         interactCharge = 0;
     }
     if (interactCharge >= 0.5f && !hasGem && hasBomb && !atGem && !atSupply && !atSwitch && !atCannon)
     {
         hasBomb = false;
         BombControl bc = mybomb.GetComponent <BombControl>();
         bc.primed = true;
     }
 }
Пример #4
0
 private void OnTriggerStay2D(Collider2D collision)
 {
     PlayerControl player = collision.GetComponent<PlayerControl>();
     if (player != null)
     {
         BombControl bomb = transform.parent.GetComponentInChildren<BombControl>();
         switch (bomb.relativePosition)
         {
             case BombControl.Position.Up:
                 if (player.transform.position.y < bomb.transform.position.y)
                     StartCoroutine(StartSequence());
                 break;
             case BombControl.Position.Middle:
                 StartCoroutine(StartSequence());
                 break;
             case BombControl.Position.Down:
                 if (player.transform.position.y > bomb.transform.position.y)
                     StartCoroutine(StartSequence());
                 break;
         }
     }
 }
Пример #5
0
    void OnCollisionEnter(Collision collision)
    {
        if (!collisionEnabled)
        {
            return;
        }

        string otherTag = collision.gameObject.tag;

        switch (otherTag)
        {
        case "Enemy":
            EnemyControl ec = collision.gameObject.GetComponent <EnemyControl>();
            if (ec)
            {
                if (ec.gameObject.name == "SpaceInvader")
                {
                    SpaceInvaderControl sc = (SpaceInvaderControl)ec;
                    sc.Action(gm);
                }
                else if (ec.gameObject.name == "Goomba")
                {
                    GoombaControl gc = (GoombaControl)ec;
                    gc.Action(gm);
                }
                else if (ec.gameObject.name == "Bomb")
                {
                    BombControl bc = (BombControl)ec;
                    bc.Action(gm);
                    gm.AddStamina(-100);
                    gameObject.SetActive(false);
                    GameObject explosion = Instantiate(Resources.Load("Prefabs/Explosion")) as GameObject;
                    explosion.transform.position = gameObject.transform.position;
                }
                else if (ec.gameObject.name == "Ghost")
                {
                    GhostControl gc = (GhostControl)ec;
                    gc.Action(gm);
                }
                else
                {
                    //se.PlaySE("cry");
                    //ec.Action(gm);
                }
            }

            break;

        case "River":
            if (!isJumping)
            {
                //GetComponent<Renderer>().isVisible = false;
                RiverControl rc = collision.gameObject.GetComponent <RiverControl>();
                if (rc)
                {
                    rc.Action(gm);
                }
                gameObject.SetActive(false);
                GameObject splash = Instantiate(Resources.Load("Prefabs/Splash")) as GameObject;
                splash.transform.position = gameObject.transform.position;
            }

            break;

        case "Collectible":
            CollectibleControl cc = collision.gameObject.GetComponent <CollectibleControl>();
            if (cc.gameObject.name == "Cherry")
            {
                gm.MakeGhostsVulnerable();
                //CherryControl cherry = (CherryControl)cc;
                //cherry.Action(gm);
                cc.Action(gm);
            }
            else
            {
                cc.Action(gm);
            }


            break;
        }
    }