示例#1
0
        public override void Update(GridPosition pos)
        {
            base.Update(pos);

            if (secondary != null)
            {
                return;
            }
            if (pos.Equals(Target.CurrentPosition))
            {
                return;
            }

            int selecteddir = InputHandlerer.GetDirectionFromInput();

            if (selecteddir == 1)
            {
                Target.PreviousTarget();
                BattleUIContainer._instance.UnitView.SetDamagePreview(Character.GetCharacterAtTile(Target.CurrentPosition).stats, activator.stats);
            }
            else if (selecteddir == 3)
            {
                Target.NextTarget();
                BattleUIContainer._instance.UnitView.SetDamagePreview(Character.GetCharacterAtTile(Target.CurrentPosition).stats, activator.stats);
            }



            GameManager._intance.StartCoroutine(GameManager.BlockInput(GameManager.controlsMode));
        }
示例#2
0
 public void Spawn()
 {
     body.gameObject.SetActive(true);
     spawned         = true;
     inputeHandlerer = new InputHandlerer();
     MoveInstant(SpawnPositon);
     FaceDirection(SpawnDirection + 1);
     UIManager._instance.CreateHPbar(body);
     body.hpBar.UpdateBar((float)stats.CurrentHP / (float)stats.CalculatedHP);
 }
示例#3
0
        protected IEnumerator MovementMidpoint(float time)
        {
            yield return(new WaitForSeconds(time));

            GridPosition tempPos = Position.Clone();

            TruePosition = Position.Clone();

            body.GetComponent <SpriteRenderer>().sortingOrder = InputHandlerer.GetSortingOrder(this) + 5;
            body.shadowRenderer.sortingOrder = body.sRenderer.sortingOrder - 1;
        }
示例#4
0
        protected IEnumerator MovementMidpointAttack(float time)
        {
            yield return(new WaitForSeconds(time));

            //  if (targetEnemy != null)targetEnemy.RecieveAttack();
            anim.Play("Attack");
            GridPosition tempPos = Position.Clone();

            TruePosition = Position.Clone();

            body.GetComponent <SpriteRenderer>().sortingOrder = InputHandlerer.GetSortingOrder(this) + 5;
            body.shadowRenderer.sortingOrder = body.sRenderer.sortingOrder - 1;
        }
 public void DisplayRange(List <GridPosition> posses, RangeType rType)
 {
     currentRangeType = rType;
     Clear();
     Container = new GameObject();
     foreach (GridPosition pos in posses)
     {
         GridPosition pos2 = pos.Clone();
         GameObject   go   = GameObject.Instantiate(UIManager._instance.rangeTilePrefabs[(int)rType]);
         go.transform.position = GameGrid.currentGrid.GetPositionOf(pos2.y, pos2.x, pos2.z) + GameGrid.BlockDirections.UP / 2;
         pos2.z--;
         go.GetComponent <SpriteRenderer>().sortingOrder = InputHandlerer.GetSortingOrder(pos2) + 1;
         hightlighters.Add(go);
         go.transform.parent = Container.transform;
     }
 }
示例#6
0
        public void MoveInstant(GridPosition pos)
        {
            GameTile tile = GameGrid.currentGrid.GetTile(pos);

            if (tile)
            {
                body.transform.position = tile.CenterPoint + topOffset;

                Position = pos.Clone();

                TruePosition = Position.Clone();
                body.sRenderer.sortingOrder      = InputHandlerer.GetSortingOrder(this);
                body.shadowRenderer.sortingOrder = body.sRenderer.sortingOrder - 1;
            }
            else
            {
                Debug.LogWarning("No Tile At Spawnpoint : " + pos);
            }
        }
示例#7
0
        protected void WalkTo(GridPosition nextTile)
        {
            TruePosition = Position.Clone();
            int lastDir = Faceddirection;

            Faceddirection = InputHandlerer.GetDirectionTo(Position, nextTile);

            SetAnimatorDirection(Faceddirection);
            if (lastDir != Faceddirection)
            {
                //   Debug.Log("Turn " + Faceddirection);
                anim.Play("Walk");
            }

            if (GameGrid.currentGrid.isInBounds(nextTile))
            {
                GridPosition     selectedTile;
                GameGrid.WalType canWalk = GameGrid.currentGrid.CanBeWalked(Position, nextTile, out selectedTile);
                if (canWalk == GameGrid.WalType.JumUp || Position.z != nextTile.z)
                {
                    int height = nextTile.z - Position.z;
                    if (height < 0)
                    {
                        height = 1;
                    }
                    Position = nextTile;

                    StartJump(GameGrid.currentGrid.GetWalkPoint(nextTile) + topOffset, height - 1);
                }
                else if (canWalk == GameGrid.WalType.CanWalk)
                {
                    Position = nextTile;
                    iTween.MoveTo(body.gameObject, iTween.Hash("position", GameGrid.currentGrid.GetTile(selectedTile).CenterPoint + topOffset, "time", Options._instance.CharacterMovementSpeed, "easetype", iTween.EaseType.linear));
                    body.StartCoroutine(MovementMidpoint(Options._instance.CharacterMovementSpeed / 2));
                    body.StartCoroutine(MoveEnabler(Options._instance.CharacterMovementSpeed));
                }
            }
        }
示例#8
0
        private GridPosition MoveTarget()
        {
            GridPosition newPos = Target.CurrentPosition;

            if (Input.GetAxisRaw("Vertical") != 0 || Input.GetAxisRaw("Horizontal") != 0)
            {
                int          selecteddir    = InputHandlerer.GetDirectionFromInput();
                GridPosition futurePosition = Target.CurrentPosition.Clone();


                if (selecteddir == 3)
                {
                    futurePosition.y++;
                }
                else if (selecteddir == 1)
                {
                    futurePosition.y--;
                }
                else if (selecteddir == 2)
                {
                    futurePosition.x++;
                }
                else if (selecteddir == 4)
                {
                    futurePosition.x--;
                }

                GridPosition pos;
                if (GameGrid.currentGrid.CanBeWalked(Target.CurrentPosition, futurePosition, out pos) != GameGrid.WalType.CannotWalk)
                {
                    newPos = pos;
                }
            }

            return(newPos);
        }
示例#9
0
 public GridPosition GetForward()
 {
     return(InputHandlerer.GetMovement(Faceddirection));
 }
示例#10
0
 public void FaceTarget(GridPosition pos)
 {
     SetAnimatorDirection(InputHandlerer.GetDirectionTo(Position, pos));
 }
示例#11
0
        public override void Update(GridPosition pos)
        {
            base.Update(pos);
            if (secondary != null)
            {
                return;
            }

            RangeDisplayControls();

            if (pos.Equals(Target.CurrentPosition))
            {
                return;
            }

            int selecteddir = InputHandlerer.GetDirectionFromInput();

            if (pathDraw.GetPath().Count == 0)
            {
                activator.SetAnimatorDirection(selecteddir);
            }



            //Disable walking throught enemy
            if (pathDraw.GetPath().Count > 0)
            {
                if (Character.isOtherCharacterInTile(pathDraw.Last.Clone(), activator))
                {
                    if (pathDraw.GetPath().Count > 1)
                    {
                        if (!pathDraw.LastNode.Previous.Value.Equals(pos))
                        {
                            GameManager._intance.StartCoroutine(GameManager.BlockInput(GameManager.controlsMode));
                            return;
                        }
                    }
                }
            }


            //Are we inside of character movement range
            if (currentMovementRange.Exists(item => item.Equals(pos)))
            {
                //Did we enter the movement range?
                if (!Target.isOutside)
                {
                    Target.Clear();


                    bool characterInTile = Character.isCharacterInTile(pos);

                    if (characterInTile)
                    {
                        Character chara = Character.GetCharacterAtTile(pos);

                        if (chara != activator)
                        {
                            if (chara.TeamNumber != activator.TeamNumber && !activator.TurnActionsPreformed[0])
                            {
                                if (pathDraw.AddPath(pos))
                                {
                                    AudioManager._instance.PlayClip("Click_Standard_03");
                                    Target.Move(pos, Color.red);
                                    BattleUIContainer._instance.UnitView.SetDamagePreview(chara.stats, activator.stats);
                                    pathDraw.SetLastWaypointGraphic(Target.Indicator.gameObject);
                                    LastDirection = selecteddir;
                                }
                            }
                        }
                        else
                        {
                            //Return to same tiel as character
                            pathDraw.Destroy();
                            Target.CurrentPosition = activator.Position;
                        }
                    }
                    else
                    {
                        //No characters in tile

                        if (pathDraw.AddPath(pos))
                        {
                            AudioManager._instance.PlayClip("Click_Standard_03");
                            Target.CurrentPosition = pos.Clone();
                            LastDirection          = selecteddir;
                        }
                        BattleUIContainer.RefreshUnitView(activator);
                        BattleUIContainer._instance.UnitView.HideDamagePreview();
                    }
                }
                else
                {
                    //If we return to walkarea from outside
                }
            }
            else
            {
                if (!Target.isOutside)
                {
                    AudioManager._instance.PlayClip("Click_Standard_03");
                    secondary = new ViewAction(this, currentMovementRange);
                    Target.Move(pos, Color.white);
                    TurnManager._instance.AddCancel(secondary.Cancel);
                }
                //Move outside walkable range
                Target.isOutside = true;
            }
            GameManager._intance.StartCoroutine(GameManager.BlockInput(GameManager.controlsMode));
        }
示例#12
0
        void OnSceneGUI(SceneView sceneView)
        {
            if (EditorTools.CurrentInspectedGrid == null)
            {
                return;
            }
            Mission selectedMission = target as Mission;
            int     i = 0;

            for (i = 0; i < selectedMission.Teams.Count; i++)
            {
                for (int q = 0; q < selectedMission.Teams[i].Members.Count; q++)
                {
                    Vector3 position = EditorTools.CurrentInspectedGrid.CenterPointOnGrid(selectedMission.Teams[i].Members[q].SpawnPositon);
                    Handles.DrawLine(position, position + Vector3.up);



                    GameGrid.BlockDirections.FaceDirections facedir = selectedMission.Teams[i].Members[q].SpawnDirection;



                    Handles.DrawSolidRectangleWithOutline(CreateArrow(facedir, position), teamColors[i], Color.red);

                    // grab the center of the parent
                    Vector3 center = position + GameGrid.BlockDirections.NW / 2 + GameGrid.BlockDirections.SW / 2;
                    Handles.DrawLine(center + Vector3.zero, center + GameGrid.BlockDirections.SE);
                    Handles.DrawLine(center + Vector3.zero, center + GameGrid.BlockDirections.NE);


                    Handles.DrawLine(center + GameGrid.BlockDirections.SE, center + GameGrid.BlockDirections.SE + GameGrid.BlockDirections.NE);
                    Handles.DrawLine(center + GameGrid.BlockDirections.NE, center + GameGrid.BlockDirections.NE + GameGrid.BlockDirections.SE);

                    center += GameGrid.BlockDirections.Down;

                    /*
                     * Handles.DrawLine(center + Vector3.zero, center + GameGrid.BlockDirections.SE);
                     * Handles.DrawLine(center + Vector3.zero, center + GameGrid.BlockDirections.NE);
                     *
                     * Handles.DrawLine(center + GameGrid.BlockDirections.SE, center + GameGrid.BlockDirections.SE + GameGrid.BlockDirections.NE);
                     * Handles.DrawLine(center + GameGrid.BlockDirections.NE, center + GameGrid.BlockDirections.NE + GameGrid.BlockDirections.SE);
                     *
                     * Handles.DrawLine(center, center + GameGrid.BlockDirections.UP);
                     * Handles.DrawLine(center + GameGrid.BlockDirections.SE, center + GameGrid.BlockDirections.SE + GameGrid.BlockDirections.UP);
                     *
                     * Handles.DrawLine(center + GameGrid.BlockDirections.SE + GameGrid.BlockDirections.NE, center + GameGrid.BlockDirections.SE + GameGrid.BlockDirections.NE + GameGrid.BlockDirections.UP);
                     *
                     */
                    if (selectedMission.Teams.Count < selectedCharacterIndex[0] || selectedMission.Teams[selectedCharacterIndex[0]].members.Count < selectedCharacterIndex[1])
                    {
                        selectedCharacterIndex[0] = 0;
                        selectedCharacterIndex[1] = 0;
                        characterSelected         = false;
                    }
                    center = selectedMission.Teams[selectedCharacterIndex[0]].Members[selectedCharacterIndex[1]].SpawnPositon.z * GameGrid.BlockDirections.UP + EditorTools.CurrentInspectedGrid.transform.position - GameGrid.BlockDirections.SE + GridEditor.verticalOffset;
                    Handles.DrawLine(center + Vector3.zero, center + GameGrid.BlockDirections.SE * EditorTools.CurrentInspectedGrid.rows);
                    Handles.DrawLine(center + Vector3.zero, center + GameGrid.BlockDirections.NE * EditorTools.CurrentInspectedGrid.columns);

                    if (PreferenceWindow.ShowCrosshair)
                    {
                        Handles.DrawLine(center + GameGrid.BlockDirections.SE * EditorTools.CurrentInspectedGrid.rows / 2, center + GameGrid.BlockDirections.SE * EditorTools.CurrentInspectedGrid.rows / 2 + GameGrid.BlockDirections.NE * EditorTools.CurrentInspectedGrid.columns);
                        Handles.DrawLine(center + GameGrid.BlockDirections.NE * EditorTools.CurrentInspectedGrid.columns / 2, center + GameGrid.BlockDirections.NE * EditorTools.CurrentInspectedGrid.columns / 2 + GameGrid.BlockDirections.SE * EditorTools.CurrentInspectedGrid.rows);
                    }
                    Handles.DrawLine(center + GameGrid.BlockDirections.SE * EditorTools.CurrentInspectedGrid.rows, center + GameGrid.BlockDirections.SE * EditorTools.CurrentInspectedGrid.rows + GameGrid.BlockDirections.NE * EditorTools.CurrentInspectedGrid.columns);
                    Handles.DrawLine(center + GameGrid.BlockDirections.NE * EditorTools.CurrentInspectedGrid.columns, center + GameGrid.BlockDirections.NE * EditorTools.CurrentInspectedGrid.columns + GameGrid.BlockDirections.SE * EditorTools.CurrentInspectedGrid.rows);
                }
            }

            if (characterSelected && selectedMission.Teams.Count != 0)
            {
                if (ObjectHilighter.currentEditor == this)
                {
                    GameTile tile = EditorTools.CurrentInspectedGrid.GetTile(selectedMission.Teams[selectedCharacterIndex[0]].Members[selectedCharacterIndex[1]].SpawnPositon);
                    if (tile)
                    {
                        ObjectHilighter.Clear();
                        ObjectHilighter.Add(tile.GetComponent <SpriteRenderer>(), this);
                    }
                    else
                    {
                        ObjectHilighter.Clear();
                    }
                }

                Vector3 spawnPos = EditorTools.CurrentInspectedGrid.CenterPointOnGrid(selectedMission.Teams[selectedCharacterIndex[0]].Members[selectedCharacterIndex[1]].SpawnPositon);

                if (Event.current.type == EventType.MouseDrag)
                {
                    float     closestDist = Mathf.Infinity;
                    int       closestDir  = 0;
                    Vector3[] positions   = new Vector3[] { spawnPos, spawnPos + GameGrid.BlockDirections.NW, spawnPos + GameGrid.BlockDirections.NE, spawnPos + GameGrid.BlockDirections.SE, spawnPos + GameGrid.BlockDirections.SW, spawnPos + GameGrid.BlockDirections.UP, spawnPos + GameGrid.BlockDirections.Down };


                    for (int c = 0; c < positions.Length; c++)
                    {
                        if (Vector3.Distance(selectedCharacterDragPosition, positions[c]) < closestDist)
                        {
                            closestDir  = c;
                            closestDist = Vector3.Distance(selectedCharacterDragPosition, positions[c]);
                        }
                    }
                    if (Event.current.modifiers == EventModifiers.Control)
                    {
                        if (closestDir == 5 || closestDir == 6)
                        {
                            closestDir = 0;
                        }
                    }
                    if (closestDir != 0)
                    {
                        GridPosition future = selectedMission.Teams[selectedCharacterIndex[0]].Members[selectedCharacterIndex[1]].SpawnPositon.Clone() + InputHandlerer.GetMovement(closestDir);
                        if (EditorTools.CurrentInspectedGrid.isInBounds(future))
                        {
                            Undo.RecordObject(target, "Move");
                            selectedMission.Teams[selectedCharacterIndex[0]].Members[selectedCharacterIndex[1]].SpawnPositon += InputHandlerer.GetMovement(closestDir);
                        }
                    }
                }

                if (Event.current.type == EventType.MouseUp)
                {
                    selectedCharacterDragPosition = EditorTools.CurrentInspectedGrid.CenterPointOnGrid(selectedMission.Teams[selectedCharacterIndex[0]].Members[selectedCharacterIndex[1]].SpawnPositon);
                    sceneView.Repaint();
                }

                selectedCharacterDragPosition = Handles.PositionHandle(selectedCharacterDragPosition, Quaternion.Euler(-60, 0, 45));
            }


            for (i = 0; i < selectedMission.Teams.Count; i++)
            {
                for (int q = 0; q < selectedMission.Teams[i].Members.Count; q++)
                {
                    Vector3 position       = EditorTools.CurrentInspectedGrid.CenterPointOnGrid(selectedMission.Teams[i].Members[q].SpawnPositon);
                    Vector3 buttonPosition = position + Vector3.up;
                    float   size           = 0.25f;
                    float   pickSize       = size * 2f;

                    Vector2 screenPos = HandleUtility.WorldToGUIPoint(buttonPosition);
                    Rect    areaRect  = new Rect(screenPos.x - 120 / 2, screenPos.y, 120, 50);
                    GUILayout.BeginArea(areaRect);
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button(selectedMission.Teams[i].Members[q]._Name, EditorStyles.miniButtonMid))
                    {
                        SessionState.SetInt("MissionEditor_LastTeamIndex", i);
                        SessionState.SetInt("CharacterEditor_LastCharacterIndex", q);
                        CharacterEditor newEditor = EditorWindow.CreateInstance <CharacterEditor>();
                        newEditor.Do(selectedMission.Teams[i].Members[q], selectedMission, selectedMission, false);
                        newEditor.SetParent(this);
                        auxWindow = newEditor;
                        EditorWindow.FocusWindowIfItsOpen <MissionEditor>();

                        selectedCharacterIndex        = new int[] { i, q };
                        characterSelected             = true;
                        selectedCharacterDragPosition = position;
                        ObjectHilighter.Clear();
                        ObjectHilighter.currentEditor = this;
                        Selection.activeGameObject    = null;
                    }

                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();

                    GUILayout.EndArea();
                }
            }
            Handles.Label(Vector3.up, "", EditorStyles.boldLabel);
        }
 public void SetTarget(GridPosition pos)
 {
     currentPosition = pos;
     gameObject.transform.position = GameGrid.currentGrid.GetPositionOf(pos.y, pos.x, pos.z) + GameGrid.BlockDirections.UP;
     SetSorting(InputHandlerer.GetSortingOrder(pos) + 5);
 }