Пример #1
0
 public void UnitEndHover(WSUnitManager unit)
 {
     if (_hoveredUnit == unit)
     {
         _hoveredUnit = null;
     }
 }
Пример #2
0
        public void UnitMouseEnter(WSUnitManager unit)
        {
            if (!inputEnabled)
            {
                return;
            }

            unit.FaintBackground();
            wsController.UnitHover(unit);
        }
Пример #3
0
        public void UnitMouseUpAsButton(WSUnitManager unit)
        {
            if (!inputEnabled)
            {
                return;
            }

            unit.FaintBackground();

            wsController.SelectUnit(unit);
            unitBeingDragged = null;
        }
Пример #4
0
        public void UnitMouseDown(WSUnitManager unit)
        {
            unit.FullBackground();

            if (!inputEnabled)
            {
                return;
            }

            unitBeingDragged             = unit;
            cameraHandler.dragPanEnabled = false;
        }
Пример #5
0
        private void LoadUnitPositions()
        {
            string mapName;

            if (Vaults.mapName != null)
            {
                mapName = Vaults.mapName;
            }
            else
            {
                mapName = Config.defaultMapName;
            }

            TextAsset unitLoader = (TextAsset)Resources.Load(Config.mapLocation + mapName + MapEditor.MEConfig.unitMapExtension, typeof(TextAsset));

            string[] unitDescriptions = unitLoader.text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            foreach (string description in unitDescriptions)
            {
                try {
                    //Parse file input
                    string desc;
                    string q = description.Substring(0, description.IndexOf(','));
                    desc = description.Substring(description.IndexOf(',') + 1, description.Length - description.IndexOf(',') - 1);
                    string r = desc.Substring(0, desc.IndexOf(','));
                    desc = desc.Substring(desc.IndexOf(',') + 1, desc.Length - desc.IndexOf(',') - 1);
                    string t = desc;

                    int qVal;
                    int rVal;
                    qVal = int.Parse(q);
                    rVal = int.Parse(r);

                    int p = int.Parse(t);

                    Vector2       hexCoords  = new Vector2(qVal, rVal);
                    GameObject    unitObject = Instantiate(unitPrefab, Vector3.zero, Quaternion.identity);
                    WSUnitManager unit       = unitObject.GetComponent <WSUnitManager>();
                    unit.VisiblePosition = hexCoords;
                    unit.PlayerOwner     = p;

                    _units[p].Add(unit);
                } catch { }
            }

            foreach (int p in _units.Keys.ToList())
            {
                _units[p] = _units[p].OrderBy(unit => unit.VisiblePosition.x)
                            .ThenBy(unit => unit.VisiblePosition.y)
                            .ToList();
            }
        }
Пример #6
0
        public void UnitMouseExit(WSUnitManager unit)
        {
            unit.FullBackground();

            if (!inputEnabled)
            {
                return;
            }

            wsController.UnitEndHover(unit);

            if (Input.GetMouseButton(0) && unitBeingDragged == unit)
            {
                unit.CreateUnitGhost();
            }
            unitBeingDragged = null;
        }
Пример #7
0
 public void UnitGhostReleased(WSUnitManager unit)
 {
     if (_hoveredUnit == null)
     {
         unit.EnableUnitVisual();
     }
     else
     {
         UnitBaseType tempUnit   = unit.UnitType;
         WeaponType   tempWeapon = unit.WeaponType;
         unit.UnitType           = _hoveredUnit.UnitType;
         unit.WeaponType         = _hoveredUnit.WeaponType;
         _hoveredUnit.UnitType   = tempUnit;
         _hoveredUnit.WeaponType = tempWeapon;
         unit.EnableUnitVisual();
     }
 }
Пример #8
0
 public void UnitHover(WSUnitManager unit)
 {
     _hoveredUnit = unit;
 }
Пример #9
0
 public void SelectUnit(WSUnitManager unit)
 {
     SelectedUnitIter = Units[activePlayer].IndexOf(unit);
 }