Esempio n. 1
0
    public static Mesh GetPatternMesh(WarriorPattern pattern, PatternFlags flags, Vector2 position, bool inverted = false)
    {
        List <Vector2> locations = pattern.GetLocationsForFlags(flags, inverted);
        int            sizeX     = GameData.CurrentBattle.Board.Width;

        Vector3[] vertices  = new Vector3[locations.Count * 4];
        int[]     triangles = new int[locations.Count * 6];
        Vector2[] uv        = new Vector2[vertices.Length];

        position = BoardUtils.BoardToWorldPosition(position);

        int count = 0;

        foreach (Vector2 location in locations)
        {
            int x = ((int)position.x + (int)location.x); //TODO
            int y = ((int)position.y - (int)location.y); //TODO

            if (!BoardUtils.IsInsideBoard(new Vector2(x, y)))
            {
                continue;
            }

            int vX = count * 4;
            vertices[vX]     = new Vector3(x, y);
            vertices[vX + 1] = new Vector3(x + 1, y);
            vertices[vX + 2] = new Vector3(x + 1, y + 1);
            vertices[vX + 3] = new Vector3(x, y + 1);

            int tX = count * 6;
            triangles[tX]     = vX;
            triangles[tX + 1] = vX + 1;
            triangles[tX + 2] = vX + 2;
            triangles[tX + 3] = vX;
            triangles[tX + 4] = vX + 2;
            triangles[tX + 5] = vX + 3;

            //TODO varies depending on the X
            float xOffset = (flags & PatternFlags.Attack) == PatternFlags.Attack ? 0.5f : 0.75f;
            uv[vX]     = new Vector2(xOffset, 0);
            uv[vX + 1] = new Vector2(xOffset + 0.25f, 0);
            uv[vX + 2] = new Vector2(xOffset + 0.25f, 1);
            uv[vX + 3] = new Vector2(xOffset, 1);

            count++;
        }

        Mesh mesh = new Mesh();

        mesh.vertices  = vertices;
        mesh.triangles = triangles;
        mesh.uv        = uv;
        mesh.RecalculateNormals();

        return(mesh);
    }
 void Choose(Vector2 position)
 {
     if (BoardUtils.IsInsideBoard(position) &&
         BattleSceneController.Main.SelectedActor.CanMoveTo(position) &&
         BoardUtils.IsPositionEmpty(position))
     {
         BattleSceneController.Main.SelectedActor.SetPosition(position);
         BattleSceneController.Main.PerformedMovement = true;
         GameObject.Destroy(currentPattern);
         BattleSceneController.Main.SwitchFlow(FlowState.ChooseActorToPerform);
     }
 }
    public void Update()
    {
        InfoText.text = "";

        if (!PerformMenu.Active ||
            !CanvasUtils.ElementContainsScreenPosition(PerformMenu.GetComponent <RectTransform>(), Input.mousePosition))
        {
            if (Input.GetMouseButton(1))
            {
                PerformMenu.Deactivate();

                if (Input.GetMouseButtonDown(1))
                {
                    lastMouseDragPos = Input.mousePosition;
                }
                else
                {
                    Vector3 diff = (lastMouseDragPos - Input.mousePosition) / 50f;
                    Camera.main.transform.position += diff;
                    lastMouseDragPos = Input.mousePosition;
                }
            }

            if (controllers.ContainsKey(CurrentFlow))
            {
                controllers[CurrentFlow].HandleInput();
            }
        }

        Vector2 pos = BoardUtils.ScreenToBoardPosition(Input.mousePosition);

        if (!BoardUtils.IsInsideBoard(pos))
        {
            return;
        }

        BattleObject obj = GameData.CurrentBattle.Board.GetObjectAt(pos);

        if (obj != null)
        {
            InfoText.text = obj.Description;
        }

        if (Input.GetKeyDown(KeyCode.Escape) && PerformMenu.Active)
        {
            PerformMenu.Deactivate();
        }

        if (controllers.ContainsKey(CurrentFlow))
        {
            controllers[CurrentFlow].Update();
        }
    }
Esempio n. 4
0
 void Choose(Vector2 position)
 {
     if (BoardUtils.IsInsideBoard(position))
     {
         BattleActor act = GameData.CurrentBattle.Board.GetActorAt(position);
         if (act != null && act.Owner == GameData.CurrentBattle.CurrentPlayer && !GameData.CurrentBattle.IsActorUsed(act))
         {
             if (act == BattleSceneController.Main.SelectedActor ||
                 (!BattleSceneController.Main.PerformedMovement && !BattleSceneController.Main.PerformedAttack))
             {
                 BattleSceneController.Main.PerformMenu.Activate(act, !BattleSceneController.Main.PerformedMovement && !BattleSceneController.Main.PerformedTurn,
                                                                 !BattleSceneController.Main.PerformedAttack && !BattleSceneController.Main.PerformedTurn,
                                                                 !BattleSceneController.Main.PerformedAttack && !BattleSceneController.Main.PerformedMovement &&
                                                                 !BattleSceneController.Main.PerformedTurn);
             }
         }
     }
 }
Esempio n. 5
0
    void Place(Vector2 at, BattleActor actor)
    {
        if (!BoardUtils.IsInsideBoard(at) || !BoardUtils.IsPositionEmpty(at))
        {
            return;
        }

        if ((GameData.CurrentBattle.CurrentPlayer == GameData.CurrentBattle.PlayerA &&
             at.x >= (GameData.CurrentBattle.Board.Width - GameData.CurrentBattle.Board.NeutralSize) / 2) ||
            (GameData.CurrentBattle.CurrentPlayer == GameData.CurrentBattle.PlayerB &&
             at.x < (GameData.CurrentBattle.Board.Width - GameData.CurrentBattle.Board.NeutralSize) / 2 + GameData.CurrentBattle.Board.NeutralSize))
        {
            return;
        }

        actor.SetPosition(at);
        actor.GameObject.SetActive(true);

        Next();
    }
Esempio n. 6
0
    void Choose(Vector2 position)
    {
        if (BoardUtils.IsInsideBoard(position) &&
            BattleSceneController.Main.SelectedActor.CanAttackAt(position))
        {
            BattleObject obj = GameData.CurrentBattle.Board.GetObjectAt(position);
            obj.TakeDamage(BattleSceneController.Main.SelectedActor.Type.Attack);

            BattleSceneController.Main.PerformedAttack = true;
            GameObject.Destroy(currentPattern);

            if (obj.Properties.ContainsKey("isOrb") && obj.Properties["isOrb"] == "true")
            {
                GameData.CurrentBattle.EndGameWithWinner(obj.Owner.GetEnemy());
            }
            else
            {
                BattleSceneController.Main.SwitchFlow(FlowState.ChooseActorToPerform);
            }
        }
    }