Esempio n. 1
0
    bool CheckCanFight()
    {
        bool flag = false;

        for (int i = locationX - hitDistance1; i <= locationX + hitDistance1; i++)
        {
            if (warCtrl.GetLocationIsEnemy(side, i, locationY))
            {
                flag = true;
                if ((i < locationX && transform.localScale.x < 0) ||
                    (i > locationX && transform.localScale.x > 0))
                {
                    transform.localScale = new Vector3(-transform.localScale.x,
                                                       transform.localScale.y, transform.localScale.z);
                }
            }
        }

        if (flag)
        {
            SetFight();
        }

        return(flag);
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (WarSceneController.isGamePause)
        {
            return;
        }

        if (WarSceneController.state == WarSceneController.State.Beginning ||
            WarSceneController.state == WarSceneController.State.Menu ||
            WarSceneController.state == WarSceneController.State.End ||
            WarSceneController.state == WarSceneController.State.Assault)
        {
            return;
        }

        if (state == 0)
        {
            Vector3 pos = transform.localPosition;

            pos.x += speed * Time.deltaTime;
            if (pos.x >= WarSceneController.manPosMaxX - 100 || pos.x <= -WarSceneController.manPosMaxX + 100 ||
                Mathf.Abs(pos.x - orgPosX) > 1000)
            {
                Destroy(gameObject);
                return;
            }
            transform.localPosition = pos;

            int locationX = warCtrl.GetLocationPositionX(transform.localPosition.x);
            int locationY = warCtrl.GetLocationPositionY(transform.localPosition.y);
//			int locationX = (int)((pos.x + WarSceneController.manPosMaxX) / WarSceneController.locationStepX);
//			int locationY = (int)((pos.y + WarSceneController.manPosMaxY) / WarSceneController.locationStepY);

            if (warCtrl.GetLocationIsEnemy(side, locationX, locationY))
            {
                WarSceneController.Direction dir = WarSceneController.Direction.Left;
                if (speed > 0)
                {
                    dir = WarSceneController.Direction.Right;
                }
                if (warCtrl.OnSoliderHitChecking(side, type, dir, 1, locationX, locationY))
                {
                    Destroy(gameObject);
                }
                else
                {
                    state = 1;
                    anim.PlayDefault();
                }
            }
        }
        else
        {
            timeTick += Time.deltaTime;
            transform.localPosition = new Vector3(transform.localPosition.x - speed / 5 * Time.deltaTime,
                                                  transform.localPosition.y + upspeed * Time.deltaTime, transform.localPosition.z);
            if (timeTick < 0.5f)
            {
                sprite.color = new Color(1, 1, 1, 1 - 2 * timeTick);
            }
            else
            {
                Destroy(gameObject);
            }
        }
    }