예제 #1
0
    public void SelectEchelon(EchelonBehavior echelon)
    {
        if (!MoveEcheToNode(echelon.GetNode()))
        {
            DeselectEchelon();
            selectedEchelon = echelon;
            selectedEchelon.GetComponent <Image>().color = Color.yellow;

            SelectedEchelonDescription.text = "Echelon: " + echelon.GetID() + "\nFaction: " + echelon.GetFaction();

            if (selectedEchelon.GetFaction() == Faction.Blue && !NPCs.Contains(selectedEchelon))
            {
                SelectedEchelonDescription.text += "\nSupply: " + echelon.GetSupply().x + " / " + echelon.GetSupply().y;
            }

            if (selectedEchelon.GetName().Length > 0)
            {
                SelectedEchelonDescription.text = SelectedEchelonDescription.text.Insert(0, "Name: " + selectedEchelon.GetName() + "\n");
            }

            ParachuteBehavior para = echelon as ParachuteBehavior;
            if (para != null)
            {
                SelectedEchelonDescription.text += "\nParachute CD: " + para.GetCooldown();
            }
            else
            {
                HOCBehavior HOC = echelon as HOCBehavior;
                if (HOC != null)
                {
                    SelectedEchelonDescription.text += "\nRange: " + HOC.GetRange();

                    nodesInSelectedHOCRange = HOC.GetAllNodesInRange();
                    HighlightNodesInHOCRange();
                }
            }
        }
    }
예제 #2
0
    public bool MoveEcheToNode(NodeBehavior node)
    {
        if (selectedEchelon != null)
        {
            if (selectedEchelon.GetNode().GetConnectedNodes().Contains(node))
            {
                EchelonBehavior blockingEchelon = GetEchelonAtNode(node);
                if (blockingEchelon == null)
                {
                    if ((selectedEchelon.GetFaction() == Faction.Blue && planner.GetAP() > 0) || NPCs.Contains(selectedEchelon) || selectedEchelon.GetFaction() != Faction.Blue)
                    {
                        selectedEchelon.SetNode(node);
                        selectedEchelon.gameObject.transform.position = node.gameObject.transform.position;

                        if (selectedEchelon.GetFaction() == Faction.Blue && !NPCs.Contains(selectedEchelon))
                        {
                            planner.AdjustAP(-1);
                        }

                        DeselectEchelon();
                        return(true);
                    }
                }
                else
                {
                    if (blockingEchelon.GetFaction() != selectedEchelon.GetFaction())
                    {
                        if (selectedEchelon as HOCBehavior == null)
                        {
                            if ((selectedEchelon.GetFaction() == Faction.Blue && planner.GetAP() > 0) ||
                                NPCs.Contains(selectedEchelon) || selectedEchelon.GetFaction() != Faction.Blue)
                            {
                                if (selectedEchelon.GetFaction() == Faction.Blue && !NPCs.Contains(selectedEchelon))
                                {
                                    if (selectedEchelon.GetSupply().x > 0 && selectedEchelon.GetSupply().y > 0)
                                    {
                                        UseCombatSupply(selectedEchelon);
                                        planner.AdjustAP(-1);
                                    }
                                    else
                                    {
                                        return(false);
                                    }
                                }

                                if (blockingEchelon as HOCBehavior != null ||
                                    ((regularEchelons.Contains(blockingEchelon) || blockingEchelon as ParachuteBehavior != null) &&
                                     (blockingEchelon.GetSupply().x == 0 || blockingEchelon.GetSupply().y == 0)))
                                {
                                    selectedEchelon.SetNode(node);
                                    selectedEchelon.gameObject.transform.position = node.gameObject.transform.position;
                                    RemoveEchelon(blockingEchelon);
                                }
                                else
                                {
                                    if (blockingEchelon.GetFaction() == Faction.Blue || selectedEchelon.GetFaction() == Faction.Blue)
                                    {
                                        foreach (HOCBehavior HOC in HOCs)
                                        {
                                            if (HOC.IsNodeInRange(blockingEchelon.GetNode()))
                                            {
                                                HOC.UseSupply(new Vector2Int(1, 2));
                                            }
                                        }
                                    }

                                    StartCoroutine(DetermineCombat(blockingEchelon));
                                }
                                return(true);
                            }
                        }
                    }
                    else if (selectedEchelon.GetFaction() == Faction.Blue)
                    {
                        blockingEchelon.SetNode(selectedEchelon.GetNode());
                        blockingEchelon.gameObject.transform.position = selectedEchelon.GetNode().gameObject.transform.position;
                        selectedEchelon.SetNode(node);
                        selectedEchelon.gameObject.transform.position = node.gameObject.transform.position;

                        DeselectEchelon();
                        return(true);
                    }
                }
            }
            else if (selectedEchelon as ParachuteBehavior != null)
            {
                ParachuteBehavior para = selectedEchelon as ParachuteBehavior;
                if (para.GetCooldown() == 0)
                {
                    if (GetEchelonAtNode(node) == null && (node.GetNodeType() == NodeType.Helipad || node.GetNodeType() == NodeType.HeavyHelipad ||
                                                           node.GetNodeType() == NodeType.ClosedHeli || node.GetNodeType() == NodeType.ClosedHeavyHeli))
                    {
                        para.UsePara();
                        selectedEchelon.SetNode(node);
                        selectedEchelon.gameObject.transform.position = node.gameObject.transform.position;

                        DeselectEchelon();
                        return(true);
                    }
                }
            }
        }
        return(false);
    }