예제 #1
0
    void resetplayer()
    {
        GameObject   player1 = GameObject.Find("play1");
        player_left  pl      = player1.GetComponent <player_left>();
        GameObject   player2 = GameObject.Find("play2");
        player_right pr      = player2.GetComponent <player_right>();

        if (pl != null)
        {
            pl.reset_player_left();
        }
        if (pr != null)
        {
            pr.reset_player_right();
        }

        AI_1 ai = player2.GetComponent <AI_1>();

        if (ai != null)
        {
            ai.reset_AI();
        }

        GameObject rd = GameObject.Find("RightDoor");

        rd.transform.position = new Vector3(18.3f, 0, 0);
        GameObject ld = GameObject.Find("LeftDoor");

        ld.transform.position = new Vector3(-18.3f, 0, 0);
        GameObject wall = GameObject.Find("wall");

        wall.transform.position = new Vector3(0, 15, 0);
    }
예제 #2
0
    void player_ai()
    {
        int dothis = Random.Range(0, 1000);

        if (dothis == 0)
        {
            if (ai.mana > 0 && Time.time > nextCast3 && ai.talking == 0)
            {
                nextCast3 = Time.time + CD;
                ai.mana  -= 1;
                GameObject  oppo = GameObject.Find("play1");
                player_left pl   = oppo.GetComponent <player_left>();
                AI_1        ai1  = oppo.GetComponent <AI_1>();
                float       size = Random.Range(5, 8);
                if (pl != null)
                {
                    pl.transform.localScale = new Vector2(0.2f * size * 0.1f, 0.2f * size * 0.1f);
                }
                if (ai1 != null)
                {
                    ai1.transform.localScale = new Vector2(size, 2.6f * size);
                }
            }
        }
    }
예제 #3
0
파일: freeze.cs 프로젝트: songpeize/SUMAHDE
    IEnumerator stop_AI(AI_1 ai)
    {
        ai.baseSpeed = 0;
        yield return(new WaitForSeconds(0.5f));

        ai.baseSpeed = 250;
    }
예제 #4
0
파일: evolve.cs 프로젝트: songpeize/SUMAHDE
 // Start is called before the first frame update
 void Start()
 {
     pl = GetComponent <player_left>();
     pr = GetComponent <player_right>();
     ai = GetComponent <AI_1>();
     if (pl != null)
     {
         player = 0;
     }
     if (pr != null)
     {
         player = 1;
     }
     if (ai != null)
     {
         player = 2;
     }
 }
예제 #5
0
파일: freeze.cs 프로젝트: songpeize/SUMAHDE
 void player_left()
 {
     if (Input.GetKeyDown(KeyCode.Y))
     {
         if (pl.mana > 0 && Time.time > nextCast1)
         {
             nextCast1 = Time.time + CD;
             pl.mana  -= 1;
             GameObject   op = GameObject.Find("play2");
             player_right pr = op.GetComponent <player_right>();
             AI_1         ai = op.GetComponent <AI_1>();
             if (pr != null)
             {
                 StartCoroutine(stop_right(pr));
             }
             if (ai != null)
             {
                 StartCoroutine(stop_AI(ai));
             }
         }
     }
 }
예제 #6
0
파일: XMark.cs 프로젝트: songpeize/SUMAHDE
    void player_ai()
    {
        int dothis = Random.Range(0, 1000);

        if (dothis == 0)
        {
            if (ai.mana > 0 && Time.time > nextCast3 && ai.talking == 0)
            {
                ai.mana -= 1;
                GameObject oppo = GameObject.Find("play1");
                //player_left pl = oppo.GetComponent<player_left>();
                AI_1       ai1  = oppo.GetComponent <AI_1>();
                float      size = Random.Range(5, 8);
                GameObject x3;

                if (GlobalControl.Instance.level == 3)
                {
                    x3 = GameObject.Find("XMark4");
                }
                else
                {
                    x3 = GameObject.Find("XMark3");
                }

                if (x3.transform.position.x == 100 && x3.transform.position.y == 100)
                {
                    x3.transform.position = ai.transform.position;
                }
                else
                {
                    nextCast3             = Time.time + CD;
                    ai.mana              -= 1;
                    ai.transform.position = x3.transform.position;
                    x3.transform.position = new Vector3(100, 100, 0);
                }
            }
        }
    }
예제 #7
0
 void player_left()
 {
     if (Input.GetKeyDown(KeyCode.T))
     {
         if (pl.mana > 0 && Time.time > nextCast1)
         {
             nextCast1 = Time.time + CD;
             pl.mana  -= 1;
             GameObject   oppo = GameObject.Find("play2");
             player_right pr   = oppo.GetComponent <player_right>();
             AI_1         ai1  = oppo.GetComponent <AI_1>();
             float        size = Random.Range(5, 8);
             if (pr != null)
             {
                 pr.transform.localScale = new Vector2(0.2f * size * 0.1f, 0.2f * size * 0.1f);
             }
             if (ai1 != null)
             {
                 ai1.transform.localScale = new Vector2(0.2f * size * 0.1f, 0.2f * size * 0.1f);
             }
         }
     }
 }
예제 #8
0
파일: evolve.cs 프로젝트: songpeize/SUMAHDE
    IEnumerator waiter_a(AI_1 w)
    {
        yield return(new WaitForSeconds(0.5f));

        w.baseSpeed = w.baseSpeed / 2;
    }
예제 #9
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        Rigidbody2D clone;

        if (other.tag == "LeftDoor")
        {
            GameObject  player_left = GameObject.Find("play1");
            player_left pl          = player_left.GetComponent <player_left>();
            if (pl)
            {
                pl.health -= 1;
            }
            GameObject  ball = GameObject.Find("Ball");
            Rigidbody2D body = ball.GetComponent <Rigidbody2D>();
            body.velocity = new Vector2(0, 0);
            who           = Random.Range(0, 2);
            if (who == 0)
            {
                body.transform.position = new Vector3(13, 0, 0);
                GameObject cball = GameObject.Find("Ball(Clone)");
                if (cball != null)
                {
                    Destroy(cball);
                }
                GameObject portal = GameObject.Find("portal");
                Map3       m3     = portal.GetComponent <Map3>();
                if (m3 != null)
                {
                    Map3 p = portal.GetComponent <Map3>();
                    p.timer1 = 1.0f;
                }
            }
            else
            {
                body.transform.position = new Vector3(-13, 0, 0);
                GameObject cball = GameObject.Find("Ball(Clone)");
                if (cball != null)
                {
                    Destroy(cball);
                }
                GameObject portal = GameObject.Find("portal");
                Map3       m3     = portal.GetComponent <Map3>();
                if (m3 != null)
                {
                    Map3 p = portal.GetComponent <Map3>();
                    p.timer1 = 1.0f;
                }
            }
            resetplayer();
        }

        if (other.tag == "RightDoor")
        {
            GameObject   player_right = GameObject.Find("play2");
            player_right pr           = player_right.GetComponent <player_right>();
            AI_1         pa           = player_right.GetComponent <AI_1>();
            if (pr)
            {
                pr.health -= 1;
            }
            if (pa)
            {
                pa.health -= 1;
            }
            GameObject  ball = GameObject.Find("Ball");
            Rigidbody2D body = ball.GetComponent <Rigidbody2D>();
            body.velocity = new Vector2(0, 0);
            who           = Random.Range(0, 2);
            if (who == 0)
            {
                body.transform.position = new Vector3(13, 0, 0);
                GameObject cball = GameObject.Find("Ball(Clone)");
                Destroy(cball);
                GameObject portal = GameObject.Find("portal");
                Map3       m3     = portal.GetComponent <Map3>();
                if (m3 != null)
                {
                    Map3 p = portal.GetComponent <Map3>();
                    p.timer1 = 1.0f;
                }
            }
            else
            {
                body.transform.position = new Vector3(-13, 0, 0);
                GameObject cball = GameObject.Find("Ball(Clone)");
                Destroy(cball);
                GameObject portal = GameObject.Find("portal");
                Map3       m3     = portal.GetComponent <Map3>();
                if (m3 != null)
                {
                    Map3 p = portal.GetComponent <Map3>();
                    p.timer1 = 1.0f;
                }
            }
            resetplayer();
        }

        // if the ball touches the boarder
        if (other.tag == "Left")
        {
            transform.position = new Vector3(transform.position.x + 0.4f, transform.position.y, 0);
            _body.velocity     = new Vector2(_body.velocity.x * -1, _body.velocity.y);
        }
        if (other.tag == "Right")
        {
            transform.position = new Vector3(transform.position.x - 0.4f, transform.position.y, 0);
            _body.velocity     = new Vector2(_body.velocity.x * -1, _body.velocity.y);
        }
        if (other.tag == "Top")
        {
            transform.position = new Vector3(transform.position.x, transform.position.y - 0.4f, 0);
            _body.velocity     = new Vector2(_body.velocity.x, _body.velocity.y * -1);
        }
        if (other.tag == "Bottom")
        {
            transform.position = new Vector3(transform.position.x, transform.position.y + 0.4f, 0);
            _body.velocity     = new Vector2(_body.velocity.x, _body.velocity.y * -1);
        }
        if (other.tag == "portal")
        {
            float y = Random.Range(-10, 10);
            clone          = Instantiate(_body, _body.transform.position, _body.transform.rotation);
            clone.velocity = new Vector2(_body.velocity.x, _body.velocity.y + y);
        }
        if (other.tag == "bh2")
        {
            GameObject bh1 = GameObject.Find("BH1");
            if (_body.velocity.x > 0)
            {
                transform.position = new Vector3(bh1.transform.position.x + 1.5f, bh1.transform.position.y, bh1.transform.position.z);
            }
            else
            {
                transform.position = new Vector3(bh1.transform.position.x - 1.5f, bh1.transform.position.y, bh1.transform.position.z);
            }
        }
        if (other.tag == "bh1")
        {
            GameObject bh2 = GameObject.Find("BH2");
            if (_body.velocity.x > 0)
            {
                transform.position = new Vector3(bh2.transform.position.x + 1.5f, bh2.transform.position.y, bh2.transform.position.z);
            }
            else
            {
                transform.position = new Vector3(bh2.transform.position.x - 1.5f, bh2.transform.position.y, bh2.transform.position.z);
            }
        }
        if (other.tag == "zoom")
        {
            print(_body.velocity);
            _body.velocity /= 10;
            print(_body.velocity);
            z = 1;
        }

        // if the ball touches players
        player_left player_l = other.GetComponent <player_left>();

        if (player_l != null)
        {
            Rigidbody2D player_l_rb = player_l.GetComponent <Rigidbody2D>();
            touchPlayer(player_l_rb);
        }

        player_right player_r = other.GetComponent <player_right>();

        if (player_r != null)
        {
            Rigidbody2D player_r_rb = player_r.GetComponent <Rigidbody2D>();
            touchPlayer(player_r_rb);
        }

        AI_1 ai = other.GetComponent <AI_1>();

        if (ai != null)
        {
            touchPlayer(ai._body);
        }
    }