Beispiel #1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     RiskMapCreater.GetTheInstance().CreateOneWisdom();
     RiskMapCreater.GetTheInstance().SnakeEatTheWisdom(transform.position);
     Snake.GetTheInstance().GetWisdom();
     Destroy(this.gameObject);
 }
Beispiel #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     Snake.GetTheInstance().GetMine();
     RiskMapCreater.GetTheInstance().SetMapPosZero(transform.position);
     RiskMapCreater.GetTheInstance().CreateOneMine();
     Destroy(this.gameObject);
 }
Beispiel #3
0
    private void FixedUpdate()
    {
        if (wisdomNum == 0)
        {
            //蛇头相对鼠标的位移矢量(世界坐标)
            dHeadTowards = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;


            //蛇头相对鼠标的位移矢量的模长平方小于1.6则不进行方向和位置的变化避免出现抖动
            if (dHeadTowards.sqrMagnitude > 1.6f)
            {
                transform.up = dHeadTowards;
                SetVelocity();
            }
        }
        else
        {
            if ((tarPosition - transform.position).sqrMagnitude < 0.1f)
            {
                tarPosition = RiskMapCreater.GetTheInstance().GetNextTarPos();
            }
            transform.up = tarPosition - transform.position;
            if (whetherHighSpeed)
            {
                transform.position += transform.up * snakeSpeed * highSpeedK * Time.fixedDeltaTime;
            }
            else
            {
                transform.position += transform.up * snakeSpeed * Time.fixedDeltaTime;
            }
        }

        SetHistoryArray();
    }
Beispiel #4
0
    public void SnakeEatTheWisdom(Vector3 setPos)
    {
        RiskMapCreater.GetTheInstance().SetMapPosZero(setPos);

        //foodPosList.Remove(setPos);
        SetFindMap();
        GetTheWay();
    }
Beispiel #5
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        RiskMapCreater.GetTheInstance().RemoveOneFood(transform.position);
        RiskMapCreater.GetTheInstance().CreateOneFood();


        Snake.GetTheInstance().GetOneFood();
        Destroy(this.gameObject);
    }
Beispiel #6
0
    public void GetWisdom()
    {
        SoundPlayer.PlayItemsSound(6);
        wisdomNum = 4;
        thisSpriteRenderer.sprite = snakeDizzyHeadSpr;
        thisRigidbody2d.velocity  = Vector3.zero;

        tarPosition = RiskMapCreater.GetTheInstance().GetNextTarPos();
        //Time.timeScale = 0;
    }
Beispiel #7
0
 //吃到物体后触发的方法
 public void GetOneFood()
 {
     RiskMapCreater.GetTheInstance().ClearTarPosList();
     RiskGameManager.GetTheInstance().SetScore(0);
     wisdomNum--;
     if (wisdomNum < 0)
     {
         wisdomNum = 0;
     }
     else if (wisdomNum == 0)
     {
         BackFromWisdom();
     }
     else
     {
         RiskMapCreater.GetTheInstance().SnakeGetTheWisdom();
     }
     AddOneBody();
     SoundPlayer.PlayItemsSound(0);
     RiskGameManager.GetTheInstance().SetLenText(snakeLength);
 }
Beispiel #8
0
    private void Awake()
    {
        theInstance = this;
        //用于测试

        /*
         * Vector3 tobjpos = new Vector3(0f, 0f, 0f);
         * for (int i = -50; i <= 50; i++)
         * {
         *  for (int j = -50; j <= 50; j++)
         *  {
         *      tobjpos.x = i;
         *      tobjpos.y = j;
         *      gameobjMap[60 + i, 60 + j] = Instantiate(testObj, tobjpos, Quaternion.identity) as GameObject;
         *  }
         * }
         */

        SetStartData();

        LoadItems();

        CreateItems();
    }
Beispiel #9
0
 public void RemoveOneFood(Vector3 setPos)
 {
     RiskMapCreater.GetTheInstance().SetMapPosZero(setPos);
     foodPosList.Remove(setPos);
 }