Exemple #1
0
    void CheckLocationState()
    {
        locationX = warCtrl.GetLocationPositionX(transform.localPosition.x);
        locationY = warCtrl.GetLocationPositionY(transform.localPosition.y);
//		locationX = (int)((transform.localPosition.x + manPosMaxX) / locationStepX);
//		locationY = (int)((transform.localPosition.y + manPosMaxY) / locationStepY);

        SetMapLocation();
    }
Exemple #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);
            }
        }
    }
    void CheckLocationState()
    {
        locationX = warCtrl.GetLocationPositionX(transform.localPosition.x);
        locationY = warCtrl.GetLocationPositionY(transform.localPosition.y);

        SetMapLocation();

        if (state == State.Magic ||
            WarSceneController.state == WarSceneController.State.Dead ||
            WarSceneController.state == WarSceneController.State.End)
        {
            return;
        }

        isStopped = false;
        bool flag = false;

        if (Random.Range(0, 100) > 50)
        {
            flag = true;
            for (int i = locationX + 1; i <= locationX + (int)(hitDistance / locationStepX); i++)
            {
                if (i >= manPosMaxX * 2 / locationStepX)
                {
                    continue;
                }
                if (warCtrl.GetLocationFlag(i, locationY) != 0)
                {
                    if (side == WarSceneController.WhichSide.Left)
                    {
                        if (warCtrl.GetLocationSide(i, locationY) == side)
                        {
                            if (state != State.Escape && i == locationX + 1)
                            {
                                isStopped = true;
                            }
                        }
                        else
                        {
                            if (state != State.Escape)
                            {
                                SetAttackFront();
                            }
                            break;
                        }
                    }
                    else
                    {
                        if (warCtrl.GetLocationSide(i, locationY) != side)
                        {
                            if (state != State.Escape)
                            {
                                SetAttackBack();
                            }
                            else
                            {
                                SetAttackFront();
                            }
                        }
                        else
                        {
                            if (state == State.Escape && i == locationX + 1)
                            {
                                isStopped = true;
                            }
                        }
                    }
                }
            }
        }

        if (isFighting)
        {
            return;
        }

        for (int i = locationX - (int)(hitDistance / locationStepX); i < locationX; i++)
        {
            if (i <= 0)
            {
                continue;
            }
            if (warCtrl.GetLocationFlag(i, locationY) != 0)
            {
                if (side == WarSceneController.WhichSide.Right)
                {
                    if (warCtrl.GetLocationSide(i, locationY) == side)
                    {
                        if (state != State.Escape && i == locationX - 1)
                        {
                            isStopped = true;
                        }
                    }
                    else
                    {
                        if (state != State.Escape)
                        {
                            SetAttackFront();
                        }
                        break;
                    }
                }
                else
                {
                    if (warCtrl.GetLocationSide(i, locationY) != side)
                    {
                        if (state != State.Escape)
                        {
                            SetAttackBack();
                        }
                        else
                        {
                            SetAttackFront();
                        }
                    }
                    else
                    {
                        if (state == State.Escape && i == locationX - 1)
                        {
                            isStopped = true;
                        }
                    }
                }
            }
        }

        if (isFighting)
        {
            return;
        }

        if (!flag)
        {
            for (int i = locationX + 1; i <= locationX + (int)(hitDistance / locationStepX); i++)
            {
                if (i >= manPosMaxX * 2 / locationStepX)
                {
                    continue;
                }
                if (warCtrl.GetLocationFlag(i, locationY) != 0)
                {
                    if (side == WarSceneController.WhichSide.Left)
                    {
                        if (warCtrl.GetLocationSide(i, locationY) == side)
                        {
                            if (state != State.Escape && i == locationX + 1)
                            {
                                isStopped = true;
                            }
                        }
                        else
                        {
                            if (state != State.Escape)
                            {
                                SetAttackFront();
                            }
                            break;
                        }
                    }
                    else
                    {
                        if (warCtrl.GetLocationSide(i, locationY) != side)
                        {
                            if (state != State.Escape)
                            {
                                SetAttackBack();
                            }
                            else
                            {
                                SetAttackFront();
                            }
                        }
                        else
                        {
                            if (state == State.Escape && i == locationX + 1)
                            {
                                isStopped = true;
                            }
                        }
                    }
                }
            }
        }
    }