Beispiel #1
0
        private void EnterSelectMove(BaseSam movingUnit)
        {
            var adapter = new TileAdapter();

            savedPath = adapter.GetPathMove(movingUnit.X, movingUnit.Y, movingUnit.Mov, (byte)ConfigDatas.CampConfig.Indexer.Reborn);
            stage     = ControlStage.SelectMove;
            refreshAll.Fire();
        }
Beispiel #2
0
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            ControlStage t = target as ControlStage;

            // Format Enum names
            string[] displayLabels = StringFormatter.FormatEnumNames(t.Display, "<None>");
            displayProp.enumValueIndex = EditorGUILayout.Popup("Display", (int)displayProp.enumValueIndex, displayLabels);

            string replaceLabel = "Portrait Stage";

            if (t.Display == StageDisplayType.Swap)
            {
                CommandEditor.ObjectField <Stage>(replacedStageProp,
                                                  new GUIContent("Replace", "Character to swap with"),
                                                  new GUIContent("<Default>"),
                                                  Stage.activeStages);
                replaceLabel = "With";
            }

            if (Stage.activeStages.Count > 0)
            {
                CommandEditor.ObjectField <Stage>(stageProp,
                                                  new GUIContent(replaceLabel, "Stage to display the character portraits on"),
                                                  new GUIContent("<Default>"),
                                                  Stage.activeStages);
            }

            bool  showOptionalFields = true;
            Stage s = t._Stage;

            // Only show optional portrait fields once required fields have been filled...
            if (t._Stage != null)            // Character is selected
            {
                if (t._Stage == null)        // If no default specified, try to get any portrait stage in the scene
                {
                    s = GameObject.FindObjectOfType <Stage>();
                }
                if (s == null)
                {
                    EditorGUILayout.HelpBox("No portrait stage has been set.", MessageType.Error);
                    showOptionalFields = false;
                }
            }
            if (t.Display != StageDisplayType.None && showOptionalFields)
            {
                EditorGUILayout.PropertyField(useDefaultSettingsProp);
                if (!t.UseDefaultSettings)
                {
                    EditorGUILayout.PropertyField(fadeDurationProp);
                }
                EditorGUILayout.PropertyField(waitUntilFinishedProp);
            }
            serializedObject.ApplyModifiedProperties();
        }
Beispiel #3
0
        private void AfterMove(int x, int y)
        {
            stage = ControlStage.Decide;

            savedPath = null;
            battleMenu.Clear();
            battleMenu.Add("attack", "攻击");
            battleMenu.Add("stop", "待机");
            battleMenu.Add("cancel", "取消");
            battleMenu.Show(x * TileManager.CellSize - baseX + TileManager.CellSize, y * TileManager.CellSize - baseY);
        }
Beispiel #4
0
        private void SelectAndMove(int x, int y)
        {
            var selectTarget = savedPath.Find(cell => cell.NowCell.X == x && cell.NowCell.Y == y);

            if (selectTarget != null)
            {
                stage = ControlStage.Move;
                DoMove(moveId, x, y, savedPath, AfterMove);
                savedPath = null;

                refreshAll.Fire();
            }
        }
Beispiel #5
0
    private void HandlePositionInput()
    {
        if (MouseHasMoved() && !isStriking)
        {
            ray = camera.ScreenPointToRay(Input.mousePosition);
            RaycastHit[] hits = Physics.RaycastAll(ray);

            if (Array.Exists(hits, hit => hit.collider.gameObject == cueBall))
            {
                hit           = Array.Find(hits, hit => hit.collider.gameObject == cueBall);
                pointToStrike = hit.point;

                if (!markerInstance)
                {
                    markerInstance = Instantiate <StrikeMarker>(strikePointMarker);
                    markerInstance.transform.position = pointToStrike;
                    markerInstance.CompleteSetup     += HandleForceSetupCompletion;
                }
                else
                {
                    markerInstance.transform.position = pointToStrike;
                }

                forceVector = (cueBall.transform.position - markerInstance.transform.position);
                markerInstance.transform.LookAt(cueBall.transform.position);
            }
            else
            {
                if (markerInstance != null)
                {
                    GameObject.Destroy(markerInstance.gameObject);
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Mouse0) && markerInstance != null)
        {
            controlStage = ControlStage.SetForce;
            markerInstance.SetPosition();
        }
    }
Beispiel #6
0
        private IEnumerator DelayAttack(BaseSam atkUnit, BaseSam targetUnit)
        {
            yield return(new NLWaitForSeconds(0.2f));

            var unitPos  = new Point(targetUnit.X * TileManager.CellSize - baseX, targetUnit.Y * TileManager.CellSize - baseY);
            var unitSize = new Size(TileManager.CellSize, TileManager.CellSize);

            if (targetUnit.OnAttack(atkUnit))
            {
                var effectDie = new StaticUIImageEffect(EffectBook.GetEffect("shrink"), HSIcons.GetImage("Samurai", targetUnit.Cid), unitPos, unitSize);
                effectRun.AddEffect(effectDie);
            }

            if (atkUnit.Camp == (byte)ConfigDatas.CampConfig.Indexer.Reborn) //todo 略ws
            {
                stage = ControlStage.None;
            }

            atkUnit.IsFinished = true;//攻击并结束回合
            OnUnitFinish();
        }
Beispiel #7
0
        private void DoAttack(int atkId, int targetId)
        {
            var atkUnit    = battleManager.GetSam(atkId);
            var targetUnit = battleManager.GetSam(targetId);

            var unitPos = new Point(targetUnit.X * TileManager.CellSize - baseX,
                                    targetUnit.Y * TileManager.CellSize - baseY);
            var unitSize = new Size(TileManager.CellSize, TileManager.CellSize);

            var effect = new StaticUIEffect(EffectBook.GetEffect("hit1"), unitPos, unitSize);

            effectRun.AddEffect(effect);

            coroutineManager.StartCoroutine(DelayAttack(atkUnit, targetUnit));

            if (atkUnit.Camp == (byte)ConfigDatas.CampConfig.Indexer.Reborn)  //todo 略ws
            {
                attackId  = 0;
                savedPath = null;
                stage     = ControlStage.AttackAnim;
            }

            refreshAll.Fire();
        }
Beispiel #8
0
        private void BattleMenu_OnClick(string evt)
        {
            var movingUnit = battleManager.GetSam(moveId);

            if (evt == "attack")
            {
                stage = ControlStage.AttackSelect;

                attackId = moveId;
                moveId   = 0;

                var adapter = new TileAdapter();
                savedPath = adapter.GetPathAttack(movingUnit.X, movingUnit.Y, movingUnit.Range, (byte)ConfigDatas.CampConfig.Indexer.Reborn);
            }
            else if (evt == "stop")
            {
                attackId  = 0;
                savedPath = null;
                stage     = ControlStage.None;
                DoStop(moveId);
            }
            else if (evt == "cancel")
            {
                if (movingUnit.X != (byte)savedMovePos.X || movingUnit.Y != (byte)savedMovePos.Y)
                {
                    tileManager.Move(movingUnit.X, movingUnit.Y, (byte)savedMovePos.X, (byte)savedMovePos.Y, moveId, movingUnit.Camp);   //退回

                    movingUnit.X = (byte)savedMovePos.X;
                    movingUnit.Y = (byte)savedMovePos.Y;
                }

                EnterSelectMove(movingUnit);
            }
            refreshAll.Fire();
            battleMenu.Clear();
        }
Beispiel #9
0
        private void doubleBuffedPanel1_MouseClick(object sender, MouseEventArgs e)
        {
            if (!isPlayerRound)
            {
                return;
            }

            var x = (dragStartPos.X + baseX) / TileManager.CellSize;
            var y = (dragStartPos.Y + baseY) / TileManager.CellSize;

            if (stage == ControlStage.None)
            {
                if (mouseOnId <= 0)
                {
                    return;
                }

                var targetUnit = battleManager.GetSam(mouseOnId);
                if (targetUnit.IsFinished || targetUnit.Camp != ConfigDatas.CampConfig.Indexer.Reborn)
                {
                    return;
                }

                moveId = mouseOnId;
                EnterSelectMove(targetUnit);
            }
            else if (stage == ControlStage.SelectMove)
            {
                if (e.Button == MouseButtons.Left) //only left key
                {
                    SelectAndMove(x, y);
                }
                else
                {
                    moveId    = 0;
                    stage     = ControlStage.None;
                    savedPath = null;

                    refreshAll.Fire();
                }
            }
            else if (stage == ControlStage.AttackSelect)
            {
                if (e.Button == MouseButtons.Left)//only left key
                {
                    var selectTarget = savedPath.Find(cell => cell.NowCell.X == x && cell.NowCell.Y == y);
                    if (selectTarget != null)
                    {
                        var tileConfig = tileManager.GetTile(selectTarget.NowCell.X, selectTarget.NowCell.Y);
                        if (tileConfig.Camp > 0)
                        {
                            DoAttack(attackId, tileConfig.UnitId);
                        }
                    }
                }
                else//右键取消攻击
                {
                    var atkUnit = battleManager.GetSam(attackId);
                    AfterMove(atkUnit.X, atkUnit.Y);
                    moveId   = attackId;
                    attackId = 0;

                    refreshAll.Fire();
                }
            }
            else if (stage == ControlStage.Decide)
            {
                battleMenu.Click();
            }
        }
Beispiel #10
0
 private void HandleForceSetupCompletion()
 {
     controlStage = ControlStage.Ready;
 }