Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (updateAngle)
        {
            Vector2 dir = new Vector2(rb.velocity.x, rb.velocity.y);

            dir.Normalize();
            float angle = Mathf.Asin(dir.y) * Mathf.Rad2Deg;
            if (dir.x < 0f)
            {
                angle = 180 - angle;
            }
            bulletSpriteTransform.localEulerAngles = new Vector3(0f, 0f, angle + 45f);
        }

        time += Time.fixedDeltaTime;

        if (time > 8f)
        {
            if (sc.clientId == tc.currentTurn)
            {
                tc.Invoke("reqTurnChange", 2f);
            }
            Destroy(this.gameObject);
        }
    }
Пример #2
0
    public void OnCollisionEnter2D(Collision2D coll)
    {
        print(coll.gameObject.name);
        if (coll.gameObject.tag == "Player")
        {
            print("맞았다");

            if (sc.clientId == tc.currentTurn)
            {
                Socket.Emit("req_take_damage", new Json("damage", 12, "socketid", coll.gameObject.GetComponent <Player>().socketid).json);
            }

            Socket.Emit("req_player_batted", new Json("id", coll.gameObject.name, "dirVecX", dirVec.x, "dirVecY", dirVec.y).json);

            //coll.gameObject.GetComponent<Rigidbody2D>().AddForce(dirVec*500f);

            //카메라 설정
            GameObject.Find("MainCamera").GetComponent <Camera2D> ().SetTarget(coll.transform);

            //8초 후에 턴 바꿈
            if (sc.clientId == tc.currentTurn)
            {
                tc.Invoke("reqTurnChange", 8f);
            }
        }
    }
Пример #3
0
    public void Explode()
    {
        AudioSource.PlayClipAtPoint(explodeSound, transform.position);

        //주변 물체에게 데미지 가하기
        Vector2 explosionPos = transform.position;

        Collider2D[] colliders = Physics2D.OverlapCircleAll(explosionPos, 1f);


        foreach (Collider2D collider in colliders)
        {
            if (collider.gameObject.tag == "Player")
            {
                if (sc.clientId == tc.currentTurn)
                {
                    Socket.Emit("req_take_damage", new Json("damage", 20, "socketid", collider.gameObject.GetComponent <Player>().socketid).json);
                }
                //collider.gameObject.GetComponent<Player>().takeDamage(20);
            }
            if (collider.gameObject.tag == "Ground")
            {
                groundName = collider.gameObject.name;
            }
        }

        if (sc.clientId == tc.currentTurn)
        {
            Socket.Emit("req_destroy_ground", new Json("ground", groundName, "centerX", destructionCircle.bounds.center.x, "centerY", destructionCircle.bounds.center.y, "sizeX", destructionCircle.bounds.size.x).json);
        }



        //ui 버튼 컨트롤을 다시 플레이어로 변경
        GameObject.Find("RightButton").GetComponent <RightButtonController>().currentControl = "player";
        GameObject.Find("LeftButton").GetComponent <LeftButtonController> ().currentControl  = "player";
        GameObject.Find("JumpButton").GetComponent <JumpButtonController> ().currentControl  = "player";

        GameObject particle = Instantiate(explosionParticle, transform.position, Quaternion.identity) as GameObject;

        Destroy(particle, 2f);

        if (sc.clientId == tc.currentTurn)
        {
            tc.Invoke("reqTurnChange", 2f);
        }


        //게임오브젝트 삭제.
        Destroy(this.gameObject);
    }
Пример #4
0
    // Update is called once per frame
    void FixedUpdate()
    {
        time += Time.fixedDeltaTime;

        if (time > 8f)
        {
            if (sc.clientId == tc.currentTurn)
            {
                tc.Invoke("reqTurnChange", 2f);
            }

            Destroy(this.gameObject);
        }
    }
Пример #5
0
    IEnumerator OnCollisionEnter2D(Collision2D coll)
    {
        if (coll.gameObject.tag == "Ground")
        {
            yield return(new WaitForSeconds(3f));

            AudioSource.PlayClipAtPoint(HolySound, transform.position);

            yield return(new WaitForSeconds(2f));

            AudioSource.PlayClipAtPoint(explodeSound, transform.position);

            //주변 물체에게 데미지 가하기
            Vector2      explosionPos = transform.position;
            Collider2D[] colliders    = Physics2D.OverlapCircleAll(explosionPos, radius);

            foreach (Collider2D collider in colliders)
            {
                if (collider.gameObject.tag == "Player")
                {
                    if (sc.clientId == tc.currentTurn)
                    {
                        Socket.Emit("req_take_damage", new Json("damage", 20, "socketid", collider.gameObject.GetComponent <Player>().socketid).json);
                    }
                }
            }


            //지형파괴
            if (sc.clientId == tc.currentTurn)
            {
                Socket.Emit("req_destroy_ground", new Json("ground", coll.gameObject.name, "centerX", destructionCircle.bounds.center.x, "centerY", destructionCircle.bounds.center.y, "sizeX", destructionCircle.bounds.size.x).json);
            }



            GameObject particle = Instantiate(explosionParticle, transform.position, Quaternion.identity) as GameObject;
            Destroy(particle, 2f);

            if (sc.clientId == tc.currentTurn)
            {
                tc.Invoke("reqTurnChange", 2f);
            }



            Destroy(this.gameObject);
            yield return(null);
        }
    }
Пример #6
0
    public IEnumerator teleporting(JSONObject marker)
    {
        an.SetTrigger("teleporting");

        yield return(new WaitForSeconds(1.5f));

        this.transform.position = new Vector3(marker.GetField("markerPositionX").f, marker.GetField("markerPositionY").f, 0);
        wc.setNoWeapon();

        if (sc.clientId == tc.currentTurn)
        {
            tc.Invoke("reqTurnChange", 2f);
        }


        yield break;
    }