Esempio n. 1
0
 public GameState()
 {
     Blocks = new BlockList();
     Effects = new EffectList();
     Units = new UnitList();
     Projectiles = new ProjectileList();
 }
Esempio n. 2
0
    public void SavePlayerUnits(UnitList unitList = null)
    {
        #region List Initializating
        UnitHealth          = new List <int>();
        UnitDamage          = new List <int>();
        UnitSpeed           = new List <int>();
        UnitIconName        = new List <string>();
        UnitIsOnBattleField = new List <bool>();
        UnitBattleIndex     = new List <int>();
        UnitStatus          = new List <int>();
        #endregion

        if (unitList == null)
        {
            unitList = UnitList.instance;
        }

        int index = 0;
        foreach (CreachureStats unit in unitList.units)
        {
            UnitHealth.Add(unit.MaxHealth);
            UnitDamage.Add(unit.Damage);
            UnitSpeed.Add(unit.Speed);
            UnitIconName.Add(unit.icon.name);
            UnitIsOnBattleField.Add(unitList.isOnBattleField[index]);
            UnitBattleIndex.Add(unitList.BattleFieldIndex[index]);
            UnitStatus.Add((int)unit.status);
            index++;
        }
    }
Esempio n. 3
0
        public ProductDescriptor(string name)
        {
            Units = new UnitList();
            Name = name;

            InitNullUnit();
            InitDefaultCategory();
        }
        protected string ProcessUsesSection(string aUnitContent, string aCurrentUsesClause, UnitList aCurrentUnitList, ICollection<string> aUnits, string aMissingUsesReplacement)
        {
            bool vListModified = ProcessUsesList(aCurrentUnitList, aUnits);
            if (!vListModified)
                return aUnitContent;

            return BuildNewUsesClause(aUnitContent, aCurrentUsesClause, aCurrentUnitList, aMissingUsesReplacement);
        }
        protected override bool ProcessUnit(UnitList aUnits, UnitItem aUnit)
        {
            int vUnitIdx = aUnits.IndexOf(aUnit.Name);
            UnitItem iToFix = aUnits[vUnitIdx];
            iToFix.UsePath = aUnit.UsePath;
            iToFix.Path = aUnit.Path;

            return true;
        }
 protected void AddUnits(UnitList iList, UnitList iToAdd)
 {
     for (int vUnitIdx = iToAdd.Count - 1; vUnitIdx >= 0; vUnitIdx--)
     {
         UnitItem vUnit = iToAdd[vUnitIdx];
         if (iList.IndexOf(vUnit.Name) < 0)
             iList.Insert(0, vUnit);
     }
 }
Esempio n. 7
0
        public void Should_Be_Able_To_Add_Unit()
        {
            var unitList = new UnitList();
            var stubUnit = new Unit("a");

            unitList.AddUnit(stubUnit);

            Assert.AreEqual(1, unitList.Count());
        }
        protected override bool ProcessUnit(UnitList aUnits, UnitItem aUnit)
        {
            int vUnitIdx = aUnits.IndexOf(aUnit.Name);
            if (aUnits[vUnitIdx].Form == aUnit.Form)
                return false;

            UnitItem vToFix = aUnits[vUnitIdx];
            vToFix.Form = aUnit.Form;

            return true;
        }
        protected string BuildNewUsesClause(string aUnitContent, string aCurrentUsesClause, UnitList aCurrentUnitList, string aMissingUsesReplacement)
        {
            string vLineStarting = "";
            string vLineEnding = "";
            if (aCurrentUsesClause == "")
            {
                aCurrentUsesClause = aMissingUsesReplacement + Environment.NewLine;
                vLineStarting = aCurrentUsesClause + Environment.NewLine;
            }

            return ReplaceContent(aUnitContent, aCurrentUsesClause, vLineStarting + aCurrentUnitList.ToString() + vLineEnding);
        }
        protected override bool ProcessUnit(UnitList aUnits, UnitItem aUnit)
        {
            int vUnitIdx = aUnits.IndexOf(aUnit.Name);
            UnitItem vToDelete = aUnits[vUnitIdx];
            if (vToDelete.HasStartingConditions && !vToDelete.HasEndingConditions && vUnitIdx < aUnits.Count - 1)
                aUnits[vUnitIdx + 1].StartingConditions = vToDelete.StartingConditions;
            else
                if (vToDelete.HasEndingConditions && !vToDelete.HasStartingConditions && vUnitIdx > 0)
                    aUnits[vUnitIdx - 1].EndingConditions = vToDelete.EndingConditions;

            aUnits.RemoveAt(vUnitIdx);
            return true;
        }
        protected override void DataPortal_Execute()
        {
            // initialize business objects for population

            _attackerHouse = House.NewHouse();
            _defenderHouse = House.NewHouse();

            _attackerForces = UnitList.NewUnitList();
            _defenderForces = UnitList.NewUnitList();

            _attackerTechnologies = TechnologyList.NewTechnologyList();
            _defenderTechnologies = TechnologyList.NewTechnologyList();

            _attackerForces.ApplyTechnologies( _attackerTechnologies );
            _defenderForces.ApplyTechnologies( _defenderTechnologies );

            BindAttackData();
            CalculateAttack();
            SaveAttack();
        }
        protected UnitList GetDefaultUnits(int iCount, bool iWithPaths, bool iRelative, bool iWithConditions)
        {
            UnitList vResult = new UnitList();
            for (int vUnitIdx = 0; vUnitIdx < iCount; vUnitIdx++)
            {
                string vUnitName = "Unit" + vUnitIdx.ToString();
                string vUnitPath = "";
                if (iWithPaths)
                    if (iRelative)
                        vUnitPath = "..\\.." + "DefaultPath" + vUnitIdx.ToString();
                    else
                        vUnitPath = @"c:\windows\temp\DefaultPath" + vUnitIdx.ToString() + "\\" + vUnitName + ".pas";

                UnitItem vUnit = new UnitItem(vUnitName, vUnitPath, iWithPaths, "");
                if (iWithConditions)
                {
                    vUnit.StartingConditions = "{$IFDEF TestCondition}";
                    vUnit.EndingConditions = "{$ENDIF}";
                }

                vResult.Add(vUnit);
            }

            return vResult;
        }
 protected override bool ProcessUnit(UnitList aUnits, UnitItem aUnit)
 {
     aUnits.Add(aUnit);
     return true;
 }
        protected static UnitList SplitUnits(string iText)
        {
            UnitList vList = new UnitList();
            MatchCollection vMatches = ExecuteExpression(iText, cUnitLines);
            foreach (Match vMatch in vMatches)
            {
                string vUnitLine = GetMatchResult(1, vMatch);
                if (vUnitLine == "")
                    continue;

                UnitItem vUnit = SplitUnitInfo(vUnitLine);
                if (vUnit != null)
                    vList.Add(vUnit);
            }

            return vList;
        }
 protected abstract bool ProcessUsesList(UnitList aCurrentUnitList, ICollection<string> aUnits);
 protected void CompareUnitLists(UnitList iExpected, UnitList iActual, bool iWithPaths)
 {
     Assert.AreEqual(iExpected.Count, iActual.Count, "Wrong number of units was read");
     for (int vUnitIdx = 0; vUnitIdx < iActual.Count; vUnitIdx++)
     {
         Assert.AreEqual(iExpected[vUnitIdx].Name, iActual[vUnitIdx].Name, "Wrong name of the unit was read");
         Assert.AreEqual(iExpected[vUnitIdx].UsePath, iActual[vUnitIdx].UsePath, "Wrong HasPath was read");
         if (iWithPaths)
             Assert.AreEqual(iExpected[vUnitIdx].Path, iActual[vUnitIdx].Path, "Wrong path of the unit was read");
         Assert.AreEqual(iExpected[vUnitIdx].StartingConditions, iActual[vUnitIdx].StartingConditions, "Wrong StartingCondition was read");
         Assert.AreEqual(iExpected[vUnitIdx].EndingConditions, iActual[vUnitIdx].EndingConditions, "Wrong EndingCondition was read (" + vUnitIdx.ToString() + ")");
     }
 }
        protected void DoTestToString_MultipleUnitsInConditionals(UnitList iList, int iStartingItemIdx, int iEndingItemIdx, string iExpected)
        {
            iList[iStartingItemIdx].StartingConditions = "{$starting_condition}";
            iList[iEndingItemIdx].EndingConditions = "{$ending_condition}";

            string vActual = iList.ToString();
            Assert.AreEqual(iExpected, vActual);
        }
 protected virtual bool CanProcessUnit(UnitList aCurrentIntfUnits, UnitList aCurrentImplUnits, ICollection<string> aRequiredUnits)
 {
     return aCurrentIntfUnits.Concat<string>(aCurrentImplUnits).Intersect<string>(aRequiredUnits).Count() == aRequiredUnits.Count;
 }
Esempio n. 19
0
		public virtual UnitList GetTargets( Vector2 Distance, int Range ) {
			UnitList units = new UnitList();
			for( int i = 0; i < mUnits.Count; i++ ) {
				if( mUnits[ i ].Dead || mUnits[ i ].GetDistance( Distance ) > Range )
					continue;
				units.Add( mUnits[ i ] );
			}

			return units;
		}
 protected void DoTestInsert(UnitList iList, UnitItem iUnitItem, int iIndex)
 {
     int vOldCount = iList.Count;
     iList.Insert(iIndex, iUnitItem);
     Assert.AreEqual(vOldCount + 1, iList.Count, "Item wasn't inserted properly");
     Assert.AreEqual(iUnitItem, iList[iIndex], "Item wasn't assigned correctly");
 }
 protected void RemoveUnits(UnitList iList, IList<string> iToRemove)
 {
     for (int vUnitIdx = iList.Count - 1; vUnitIdx >= 0; vUnitIdx--)
         if (iToRemove.IndexOf(iList[vUnitIdx].Name.ToLower()) >= 0)
             iList.RemoveAt(vUnitIdx);
 }
        private int GetCheapestMilitiaID( UnitList list )
        {
            int cheapest = 0;
            foreach (Unit unit in list)
            {
                if (cheapest == 0 || unit.Cost < cheapest) cheapest = unit.ID;
            }

            return cheapest;
        }
Esempio n. 23
0
 void Start()
 {
     unitList = GameObject.Find("_Lists").GetComponent<UnitList>();
     shipComponentList = GameObject.Find("_Lists").GetComponent<ShipComponentList>();
 }
 public void Dispose()
 {
     fImplementation = null;
     fInterface = null;
 }
 public UnitStructure()
 {
     fImplementation = new UnitList();
     fInterface = new UnitList();
 }
 protected void TearDown()
 {
     fTestList = null;
 }
 protected void SetUp()
 {
     fTestList = CreateDefaultList(10, true, false);
 }
Esempio n. 28
0
 void Awake()
 {
     unitList = GameObject.Find("_Lists").GetComponent<UnitList>();
 }
Esempio n. 29
0
    void UpdateCreatures()
    {
        CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
        TextInfo textInfo = cultureInfo.TextInfo;
        unitList = DFConnection.Instance.PopUnitListUpdate();
        if (unitList == null) return;
        foreach (var unit in unitList.creature_list)
        {
            if (creatureList == null)
                creatureList = new Dictionary<int, Transform>();
            UnitFlags1 flags1 = (UnitFlags1)unit.flags1;
            //UnitFlags2 flags2 = (UnitFlags2)unit.flags2;
            //UnitFlags3 flags3 = (UnitFlags3)unit.flags3;
            if (((flags1 & UnitFlags1.dead) == UnitFlags1.dead)
                 || ((flags1 & UnitFlags1.left) == UnitFlags1.left)
                 || ((flags1 & UnitFlags1.caged) == UnitFlags1.caged)
                 || ((flags1 & UnitFlags1.forest) == UnitFlags1.forest)
                 )
            {
                if (creatureList.ContainsKey(unit.id))
                {
                    Destroy(creatureList[unit.id].gameObject);
                    creatureList.Remove(unit.id);
                }
            }
            else
            {
                CreatureRaw creatureRaw = null;
                if (DFConnection.Instance.NetCreatureRawList != null)
                    creatureRaw = DFConnection.Instance.NetCreatureRawList.creature_raws[unit.race.mat_type];

                if (!creatureList.ContainsKey(unit.id))
                {
                    creatureList[unit.id] = Instantiate(creatureTemplate);
                    creatureList[unit.id].transform.parent = gameObject.transform;
                    creatureList[unit.id].name = "Unit_" + unit.id;
                    creatureList[unit.id].GetComponentInChildren<AtlasSprite>().ClearMesh();

                    Color color = Color.white;
                    if (unit.profession_color != null)
                        color = new Color(unit.profession_color.red / 255.0f, unit.profession_color.green / 255.0f, unit.profession_color.blue / 255.0f, 1);

                    if (creatureRaw != null)
                        creatureList[unit.id].GetComponentInChildren<AtlasSprite>().AddTile(creatureRaw.creature_tile, color);

                }
                creatureList[unit.id].gameObject.SetActive(unit.pos_z < PosZ && unit.pos_z >= (PosZ - cameraViewDist));
                if (creatureList[unit.id].gameObject.activeSelf) //Only update stuff if it's actually visible.
                {
                    Vector3 position = DFtoUnityCoord(unit.pos_x, unit.pos_y, unit.pos_z);
                    creatureList[unit.id].transform.position = position + new Vector3(0, 0.51f, 0);
                    float scale;
                    if (scaleUnits)
                        scale = unit.size_info.length_cur / 391.0f;
                    else
                        scale = 1;
                    creatureList[unit.id].transform.localScale = new Vector3(scale, scale, scale);
                    creatureList[unit.id].GetComponentInChildren<Light>().range = scale * 10;
                    AtlasSprite sprite = creatureList[unit.id].GetComponentInChildren<AtlasSprite>();
                    if ((flags1 & UnitFlags1.on_ground) == UnitFlags1.on_ground)
                    {
                        sprite.transform.localPosition = Vector3.zero;
                        sprite.cameraFacing.enabled = false;
                        sprite.transform.rotation = Quaternion.Euler(90, 0, 0);
                    }
                    else
                    {
                        sprite.transform.localPosition = new Vector3(0, 1.0f, 0);
                        sprite.cameraFacing.enabled = true;
                    }
                    if (unit.profession_color != null)
                        creatureList[unit.id].GetComponentInChildren<AtlasSprite>().SetColor(0, new Color(unit.profession_color.red / 255.0f, unit.profession_color.green / 255.0f, unit.profession_color.blue / 255.0f, 1));
                    if (creatureRaw != null)
                    {
                        if (unit.is_soldier)
                            creatureList[unit.id].GetComponentInChildren<AtlasSprite>().SetTile(0, creatureRaw.creature_soldier_tile);
                        else
                            creatureList[unit.id].GetComponentInChildren<AtlasSprite>().SetTile(0, creatureRaw.creature_tile);
                        Text unitText = creatureList[unit.id].GetComponentInChildren<Text>();
                        if (unit.name == "")
                            unitText.text = textInfo.ToTitleCase(creatureRaw.caste[unit.race.mat_index].caste_name[0]);
                        else
                        {
                            unitText.text = unit.name;
                        }
                    }
                }

            }
        }
    }
Esempio n. 30
0
		public virtual Unit GetRandomTarget( Vector2 Distance, int Range ) {
			UnitList randUnits = new UnitList();
			for( int i = 0; i < mUnits.Count; i++ ) {
				if( mUnits[ i ].Dead || mUnits[ i ].GetDistance( Distance ) > Range )
					continue;
				randUnits.Add( mUnits[ i ] );
			}

			if( randUnits.Count == 0 )
				return null;
			return randUnits[ mRand.Next( randUnits.Count ) ];
		}
 protected void DoTestContains_NotExisting(UnitList iList, string iUnitPrefix, int iUnitIdx)
 {
     UnitItem vNotExisting = CreateItem(iUnitPrefix, iUnitIdx, true);
     Assert.IsFalse(iList.Contains(vNotExisting.Name), "Wrong Contains result. Item shouldn't be on the list: " + vNotExisting.Name);
 }