Example #1
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            // Escape key pressed, cancel any current mouse mode
            SelectedUnit = null;
            CancelUpdateFunc();
        }
        hexUnderMouse = MouseToHex();

        Update_CurrentFunc();

        Update_ScrollZoom();

        lastMousePosition = Input.mousePosition;
        lastHexUnderMouse = hexUnderMouse;


        // draw unit path
        if (SelectedUnit != null)
        {
            DrawPath((hexPath != null) ? hexPath : SelectedUnit.GetHexPath());
        }
        else
        {
            DrawPath(null);
        }
    }
Example #2
0
        // 「会話」コマンドを終了
        private void FinishTalkCommand()
        {
            Pilot p;

            GUI.LockGUI();
            if (SelectedUnit.CountPilot() > 0)
            {
                p = SelectedUnit.Pilots.First();
            }
            else
            {
                p = null;
            }

            // 会話イベントを実施
            Event.HandleEvent("会話", SelectedUnit.MainPilot().ID, SelectedTarget.MainPilot().ID);
            if (SRC.IsScenarioFinished)
            {
                SRC.IsScenarioFinished = false;
                return;
            }

            if (p is object)
            {
                if (p.Unit is object)
                {
                    SelectedUnit = p.Unit;
                }
            }

            GUI.UnlockGUI();

            // 行動終了
            WaitCommand();
        }
Example #3
0
    void UnitSelectionOptions()
    {
        bool unitNull = SelectedUnit == null;

        if (unitNull && ScriptLink.UIcontroller.gameStatsBar.activeSelf == true) //We are selecting
        {
            UnitSelection();
        }
        else if (unitNull == false && SelectedUnit.GetComponent <Unit>().canMove == false && SelectedUnit.GetComponent <Unit>().canAttack == true) //We are attacking
        {
            if (mouseLocation == new Vector2(SelectedUnit.transform.position.x, SelectedUnit.transform.position.y))
            {
                UnselectUnit();
            }
            if (SelectedUnit != null && SelectedUnit.GetComponent <UnitStats>().UnitIdentity == UnitStats.UnitType.Artillery && SelectedUnit.GetComponent <Unit>().artilleryCanMove == false)
            {
                SelectedUnit.GetComponent <Unit>().artilleryCanMove = true;
                UnselectUnit();
            }
            CanWeAttack();
        }
        else if (unitNull == false && SelectedUnit.gameObject.GetComponent <UnitStats>().isRed == ScriptLink.flowController.IsRedTurn) //We are moving
        {
            LocationSelection();
        }
    }
Example #4
0
    // sets the unit's movement path
    void Update_UnitMovement()
    {
        if (Input.GetMouseButtonUp(1) || SelectedUnit == null)
        {
            Debug.Log("End Unit Movement");
            //copy over pathfinding before exiting
            if (SelectedUnit != null)
            {
                SelectedUnit.SetHexPath(hexPath);
                StartCoroutine(hexMap.DoUnitMoves(SelectedUnit));
            }

            Update_CurrentFunc = CancelUpdateFunc;
            return;
        }
        //
        // we have a selected unit
        //
        // pass pathfinding data for potential unit path

        if (hexUnderMouse != null && (hexPath == null || hexUnderMouse != lastHexUnderMouse))
        {
            hexPath = QPath.QPath.FindPath <Hex>(
                hexMap,
                SelectedUnit,
                SelectedUnit.Hex,
                hexUnderMouse,
                Hex.CostEstimate);
        }
    }
        private void DrawTerrainChange(CustomSpriteBatch g, string Terrain, Texture2D Sprite, int X, int Y)
        {
            g.Draw(Sprite, new Vector2(X, Y), Color.White);
            g.DrawString(fntFinlanderFont, DicTerrainLetterAttribute[Terrain].ToString(), new Vector2(X + 25, Y + 4), Color.White);

            g.Draw(Sprite, new Vector2(X, Y + 46), Color.White);
            g.DrawString(fntFinlanderFont, SelectedUnit.TerrainLetterAttribute(Terrain).ToString(), new Vector2(X + 25, Y + 50), Color.White);
        }
 private void deleteUnitTool_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(EntryControl.Resources.Message.Question.Delete, SelectedUnit.ToString(),
                         MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         DeleteUnit(SelectedUnit);
     }
 }
 private void UpdatePartsEffects()
 {
     SelectedUnit.ResetBoosts();
     SelectedUnit.ActivePassiveBuffs();
     if (CursorIndexListPart > 0)
     {
         SystemList.ListPart.ElementAt(CursorIndexListPart - 1).Value.ActivatePassiveBuffs();
     }
 }
        private void bsUnitList_CurrentChanged(object sender, EventArgs e)
        {
            bsUnitItem.DataSource = SelectedUnit.LoadCopy(Database);

            bsNonUserList.DataSource  = SelectedUnit.GetUserList(Database, 0);
            bsCreatorGroup.DataSource = SelectedUnit.GetUserList(Database, EntryControlDatabase.MaterialCreatorGroup);
            bsSignerGroup.DataSource  = SelectedUnit.GetUserList(Database, EntryControlDatabase.MaterialSignerGroup);

            tblPanelUser.Visible = true;
        }
Example #9
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     entityPanelUIs        = new EntityInfoPanelUI[2];
     selectedUnit          = new SelectedUnit();
     selectedUnit.location = TroopLocation.NULL;
 }
Example #10
0
 void MovementTileCheck()
 {
     if (ScriptLink.tileSpreadingManager.actionTiles[(int)unitSelectionLocation.x, (int)unitSelectionLocation.y] != null)
     {
         if (ScriptLink.tileSpreadingManager.actionTiles[(int)unitSelectionLocation.x, (int)unitSelectionLocation.y].GetComponent <ActionTileProperties>().actionType == ActionTileProperties.ActionType.Movement_Valid)
         {
             SelectedUnit.GetComponent <Unit>().LocationSelected();
         }
     }
 }
Example #11
0
 /// <summary>
 /// Deselects an unit, removing the <see cref="SelectedUnit"/> component and turning it back to its default state
 /// </summary>
 private void deselectUnit()
 {
     if (SelectedUnit != null)
     {
         var selectedUnitComponent = SelectedUnit.GetComponent <SelectedUnit>();
         selectedUnitComponent.Deselect();
         Destroy(selectedUnitComponent);
         MatchManager.DeactivateUIForUnit(SelectedUnit);
         SelectedUnit = null;
     }
 }
Example #12
0
 private void UpdatePartsEffects()
 {
     SelectedUnit.ResetBoosts();
     SelectedUnit.ActivePassiveBuffs();
     if (CursorIndexListPart > 0)
     {
         GlobalBattleContext.SetContext(null, SelectedUnit, SelectedUnit.Pilot, null, SelectedUnit, SelectedUnit.Pilot, ActiveParser);
         UnitPart ActivePart = SystemList.ListPart.ElementAt(CursorIndexListPart - 1).Value;
         ActivePart.ReloadSkills(DicRequirement, DicEffect, DicAutomaticSkillTarget, DicManualSkillTarget);
         ActivePart.ActivatePassiveBuffs();
     }
 }
Example #13
0
        private void DeleteUnit()
        {
            MessageBoxResult result = MessageBox.Show(
                "Are you sure you want to delete the selected unit?", "Confirm Delete",
                MessageBoxButton.YesNoCancel, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                Storage.DeleteUnit(SelectedUnit.ToModel());
                SelectedProject.Units.Remove(SelectedUnit);
            }
        }
Example #14
0
 public void UseAttack(Unit targetUnit)
 {
     if (targetUnit != null)
     {
         //if (SelectedUnit.CanAttackTarget(targetUnit))
         //{
         SelectedUnit.TriggerAttack(targetUnit);
         RefreshEffectManager();
         GameManager.instance.uiManager.RefreshUI();
         //}
     }
 }
        private void SelectPartLinkedUnit()
        {
            PartInfo ActivePartInfo = ListPartInfo[CursorIndexListPart - 1];

            if (InputHelper.InputUpPressed())
            {
                if (CursorIndexListPartUnits > 0)
                {
                    CursorIndexListPartUnits--;
                }
                else
                {
                    CursorIndexListPartUnits = ActivePartInfo.ListUnit.Count;
                }

                UpdatePartsEffects();
            }
            else if (InputHelper.InputDownPressed())
            {
                if (CursorIndexListPartUnits + 1 < ActivePartInfo.ListUnit.Count + 1)
                {
                    CursorIndexListPartUnits++;
                }
                else
                {
                    CursorIndexListPartUnits = 0;
                }

                UpdatePartsEffects();
            }
            else if (InputHelper.InputConfirmPressed())
            {
                Unit LinkedUnit = ActivePartInfo.ListUnit[CursorIndexListPartUnits];
                for (int P = 0; P < LinkedUnit.ArrayParts.Length; ++P)
                {
                    if (LinkedUnit.ArrayParts[P] == ActivePartInfo.ActivePart)
                    {
                        LinkedUnit.ArrayParts[P] = null;
                    }
                }

                SelectedUnit.ArrayParts[CursorIndexUnitPart] = ActivePartInfo.ActivePart;
                ActivePartInfo.ListUnit.Add(SelectedUnit);
                ActivePartInfo.ListUnit.Remove(LinkedUnit);

                SelectedUnit.ResetBoosts();
                SelectedUnit.ActivePassiveBuffs();
                LinkedUnit.ResetBoosts();
                LinkedUnit.ActivePassiveBuffs();
                GoToPartChange();
            }
        }
Example #16
0
 public void SelectUnit(BaseUnit unit)
 {
     SelectedUnit?.OnUnBeSelected();
     if (unit)
     {
         unit?.OnBeSelected();
         SelectedUnit = unit;
     }
     else
     {
         SelectedUnit = null;
     }
 }
Example #17
0
    public void Imprison(Unit unit)
    {
        if (!unit.Owner.IsActivePlayer)
        {
            if (!unit.IsHero)
            {
                SelectedUnit.CaptureCard(imprisonedUnit: unit);

                RefreshEffectManager();
                GameManager.instance.uiManager.RefreshUI();
            }
        }
    }
Example #18
0
        private void Click()
        {
            Vector2i square = ScreenToGrid(Engine.MousePosition);

            if (square == null)
            {
                return;
            }

            switch (Mode)
            {
            case InterfaceMode.TargettingWarp:
                if (square == SelectedUnit.Position)
                {
                    SelectedUnit.WarpTarget    = null;
                    SelectedUnit.WarpCountdown = -1;
                }
                else if (SelectedUnit.CanWarpTo(square))
                {
                    SelectedUnit.WarpTarget    = square;
                    SelectedUnit.WarpCountdown = 3;
                }

                Mode = InterfaceMode.Normal;
                break;

            case InterfaceMode.TargettingBombard:
                //we can only get here if the selectedunit has bombard
                Unit target = Game.World.Map.At(square).Unit;
                if (target != null)
                {
                    Engine.NetClient.Send(
                        new NetMessage3(
                            NM3MessageType.unit_bombard,
                            SelectedUnit.ID,
                            target.ID
                            )
                        );
                }

                Mode = InterfaceMode.Normal;
                break;

            default:
            case InterfaceMode.Normal:
                Select(square);
                break;
            }
        }
Example #19
0
        public bool isReachable(Position targetedTile)
        {
            Position positionUnit    = SelectedUnit.Position;
            float    ptMoveAvailable = SelectedUnit.Move;
            float    ptMoveRequired  = SelectedUnit.computeMovePoint(Map.getTileAt(targetedTile));

            // Si le nombre de MovePoint est suffisant et que le déplacement est bien sur une case accessible
            if (ptMoveAvailable >= ptMoveRequired &&
                (((Math.Abs(positionUnit.X - targetedTile.X) == 1 && Math.Abs(positionUnit.Y - targetedTile.Y) == 0)) ^
                 ((Math.Abs(positionUnit.X - targetedTile.X) == 0 && Math.Abs(positionUnit.Y - targetedTile.Y) == 1))))
            {
                return(true);
            }
            return(false);
        }
 public void ShowSelectedItem()
 {
     numberTextBox.Text = ToNumber(SelectedUnit).ToString();
     messageLabel.Text  = string.Format(Resources.SelectUnitsFormSelectedUnits, SelectedUnit.GetOffOnName(CustomUnits));
     if (SelectedUnit.IsAnalog())
     {
         analogUnitsListBox.SelectedIndex  = ToNumber(SelectedUnit) - 1;
         digitalUnitsListBox.SelectedIndex = -1;
     }
     else
     {
         digitalUnitsListBox.SelectedIndex = SelectedUnit - Unit.DigitalUnused;
         analogUnitsListBox.SelectedIndex  = -1;
     }
 }
Example #21
0
        public void Input()
        {
            //handled more gracefully in the future, hopefully...
            bool     passClickToWorld = true;
            Vector2i hovered          = ScreenToGrid(Engine.MousePosition);

            if (Engine.ButtonPressed(0))
            {
                foreach (Widget w in Widgets)
                {
                    if (w.IsHovered)
                    {
                        w.OnClick();
                        passClickToWorld = false;
                    }
                }
            }

            if (Engine.ButtonPressed(2))
            {
                if (Mode != InterfaceMode.Normal)
                {
                    Mode = InterfaceMode.Normal;
                }
                else if (SelectedUnit != null && hovered != null)
                {
                    if (SelectedUnit.CanMoveTo(hovered))
                    {
                        EventHandler.Push(
                            new UnitMoveEvent(
                                SelectedUnit.ID,
                                hovered.X,
                                hovered.Y,
                                true //local, we generated it
                                )
                            );
                    }
                }
            }

            if (Engine.ButtonPressed(0) && passClickToWorld)
            {
                if (Engine.Active && Engine.MouseInside)
                {
                    Click();
                }
            }
        }
Example #22
0
        // Return true si l'unité est accessible
        public bool attackUnit(Position targetedTile)
        {
            bool     isAccessible    = false;
            Position positionUnit    = SelectedUnit.Position;
            float    ptMoveAvailable = SelectedUnit.Move;
            float    ptMoveRequired  = SelectedUnit.computeMovePoint(Map.getTileAt(targetedTile));

            // Si le nombre de MovePoint est suffisant et que l'attaque est effectuée sur une unité à portée
            if (isPossibleAttack(targetedTile))
            {
                isAccessible = true;
                AttackCommand mc = new AttackCommand(SelectedUnit.IdUnit, choseDefender(targetedTile).IdUnit, ptMoveRequired);
                mc.execute();
            }
            return(isAccessible);
        }
Example #23
0
        public bool moveUnit(Position targetedTile)
        {
            bool     isAccessible    = false;
            Position positionUnit    = SelectedUnit.Position;
            float    ptMoveAvailable = SelectedUnit.Move;
            float    ptMoveRequired  = SelectedUnit.computeMovePoint(Map.getTileAt(targetedTile));

            // Si le nombre de MovePoint est suffisant et que le déplacement est bien sur une case accessible
            if (isPossibleMove(targetedTile))
            {
                isAccessible = true;
                MoveCommand mc = new MoveCommand(SelectedUnit.IdUnit, targetedTile, ptMoveRequired);
                mc.execute();
            }
            return(isAccessible);
        }
Example #24
0
        public static void SelectUnit(BaseUnit unit)
        {
            if (IsBlockSelectUnit)
            {
                return;
            }
            //选择一个单位后无法再次选择
            if (IsInSelectUnitTime())
            {
                return;
            }
            if (unit)
            {
                //检测这个是否可以被选择
                if (!Ins.IsCanSelectUnit(unit))
                {
                    return;
                }
            }

            //检测是否重复选择
            bool isRepeat = false;

            if (SelectedUnit == unit)
            {
                isRepeat = true;
            }
            else
            {
                SelectedUnit?.OnUnBeSelected();
            }

            if (unit)
            {
                unit?.OnBeSelected(isRepeat);
                SelectedUnit = unit;
            }
            else
            {
                SelectedUnit = null;
            }
            SelectUnitTimer.Restart();
            Ins?.OnSelectedUnit(SelectedUnit, isRepeat);
        }
        private void GoToPartChange()
        {
            CurrentMaxHP       = SelectedUnit.MaxHP;
            CurrentMaxEN       = SelectedUnit.MaxEN;
            CurrentMaxArmor    = SelectedUnit.Armor;
            CurrentMaxMobility = SelectedUnit.Mobility;
            CurrentMaxMV       = SelectedUnit.MaxMovement;

            SelectedUnit.ListTerrainChoices.Clear();
            SelectedUnit.ListTerrainChoices.AddRange(ListTerrainChoices);

            DicTerrainLetterAttribute.Clear();
            DicTerrainLetterAttribute.Add("Air", SelectedUnit.TerrainLetterAttribute("Air"));
            DicTerrainLetterAttribute.Add("Land", SelectedUnit.TerrainLetterAttribute("Land"));
            DicTerrainLetterAttribute.Add("Sea", SelectedUnit.TerrainLetterAttribute("Sea"));
            DicTerrainLetterAttribute.Add("Space", SelectedUnit.TerrainLetterAttribute("Space"));

            Stage = 0;
        }
    public void SelectNextUnit(bool skipDoneUnits)
    {
        Player player = hexMap.CurrentPlayer;

        Unit[] units = player.Units;

        int currentIndex = 0;

        if (SelectedUnit != null)
        {
            for (int i = 0; i < units.Length; i++)
            {
                if (SelectedUnit == units[i])
                {
                    currentIndex = i;
                    break;
                }
            }
        }

        for (int i = 0; i < units.Length; i++)
        {
            int tryIndex = (currentIndex + i + 1) % units.Length;

            if (skipDoneUnits == true && units[tryIndex].UnitWaitingForOrders() == false)
            {
                // Skip this unit
                continue;
            }

            // We only get here if we're on a valid pick
            SelectedUnit = units[tryIndex];
            return;
        }

        // if we got here, selection did not change
        // If the pre-existing unit is done, and we're suppposed to skip that,
        // then clear the selection.
        if (SelectedUnit.UnitWaitingForOrders() == false && skipDoneUnits == true)
        {
            SelectedUnit = null;
        }
    }
Example #27
0
        public void DrawSelection()
        {
            if (Selection == null)
            {
                return;
            }
            Tile t = Game.World.Map.At(Selection.GetSelection());

            if (
                (SelectedUnit != null && t.Unit == SelectedUnit) ||
                (SelectedTile == t && t.Station != null)
                )
            {
                Vector2 position = t.Position.ToVector2();

                if (Selection.GetSelectionType() == SelectionType.Unit)
                {
                    //no i'm not going to check if it's null, it's not null.
                    //i'll fight you.
                    Debug.Assert(SelectedUnit != null, "SelectedUnit != null");

                    position =
                        SelectedUnit
                        .GetAnimateable()
                        .ApplyAnimations()
                        .Position;
                }

                fbRectangle destination =
                    Camera.WorldToScreen(
                        new fbRectangle(
                            //t.Position * tileSize,
                            position * tileSize,
                            new Vector2(tileSize)
                            )
                        );

                Engine.Draw(
                    Engine.GetTexture("ui-selection"),
                    destination
                    );
            }
        }
Example #28
0
 public void UnselectUnit()
 {
     busyWithAllyUnit = false;
     if (selectedUnit.GetComponent <Unit>().canMove == false && SelectedUnit.GetComponent <Unit>().canAttack == true) //We are attacking
     {
         selectedUnit.GetComponent <Unit>().canAttack = false;
         ScriptLink.unitMenuControl.unitInventory.SetActive(false);
     }
     if (selectedUnit.GetComponent <Unit>().canMove == false && SelectedUnit.GetComponent <Unit>().canAttack == false) //Unit done moving
     {
         ScriptLink.mouseController.SelectedUnit.GetComponent <Unit>().DarkenUnit();
     }
     if (selectedUnit != null) //We are moving
     {
         selectedUnit = null;
         ScriptLink.unitMenuControl.HideUnitMenus();
         ScriptLink.tileSpreadingManager.ClearActionTiles();
         SelectionBox.GetComponent <SpriteRenderer>().sprite = SelectionBoxYellow;
     }
 }
 //TODO: This method looks good, but I would say it should be in DAL. What do you think?
 public Task <int> InsertEntity(IEntity entity)
 {
     if (entity is Language)
     {
         return(Db.SqLiteAsyncConnection.InsertAsync(entity));
     }
     else if (entity is Level)
     {
         return(SelectedLanguage.InsertLevel(entity as Level));
     }
     else if (entity is Unit)
     {
         return(selectedLevel.InsertUnit(entity as Unit));
     }
     else if (entity is Lesson)
     {
         return(SelectedUnit.InsertLesson(entity as Lesson));
     }
     return(new Task <int>(() => 0));
 }
Example #30
0
    void CanWeAttack()
    {
        RaycastHit UnitHit;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out UnitHit, 1000.0f, unitLayerMask))
        {
            enemyUnit = UnitHit.collider.gameObject;
            if (EnemyUnit.GetComponent <UnitStats>().isRed != ScriptLink.flowController.IsRedTurn)
            {
                if (ScriptLink.tileSpreadingManager.actionTiles[(int)mouseLocation.x, (int)mouseLocation.y] != null)
                {
                    if (ScriptLink.tileSpreadingManager.actionTiles[(int)mouseLocation.x, (int)mouseLocation.y].GetComponent <ActionTileProperties>().actionType == ActionTileProperties.ActionType.Attack_Valid)
                    {
                        if (ScriptLink.tileSpreadingManager.actionTiles[(int)mouseLocation.x, (int)mouseLocation.y].transform.position.x == EnemyUnit.transform.position.x)
                        {
                            if (ScriptLink.tileSpreadingManager.actionTiles[(int)mouseLocation.x, (int)mouseLocation.y].transform.position.y == EnemyUnit.transform.position.y)
                            {
                                SelectedUnit.GetComponent <UnitAttacking>().Attack();
                            }
                        }
                    }
                }
            }
            else
            {
                if (ScriptLink.tileSpreadingManager.actionTiles[(int)mouseLocation.x, (int)mouseLocation.y] != null)
                {
                    if (ScriptLink.tileSpreadingManager.actionTiles[(int)mouseLocation.x, (int)mouseLocation.y].GetComponent <ActionTileProperties>().actionType == ActionTileProperties.ActionType.Assist_Valid)
                    {
                        if (ScriptLink.tileSpreadingManager.actionTiles[(int)mouseLocation.x, (int)mouseLocation.y].transform.position.x == EnemyUnit.transform.position.x)
                        {
                            if (ScriptLink.tileSpreadingManager.actionTiles[(int)mouseLocation.x, (int)mouseLocation.y].transform.position.y == EnemyUnit.transform.position.y)
                            {
                                SelectedUnit.GetComponent <UnitAssisting>().Assist();
                            }
                        }
                    }
                }
            }
        }
    }
Example #31
0
 // Use this for initialization
 void Start()
 {
     GameObject temp = GameObject.Find("SelectedUnit");
     selectedUnit = temp.GetComponent<SelectedUnit>();
     isAssignedTo = -1;
     isAssigned = false;
 }