Пример #1
0
		public Relationship DefineRelationshipTo(Faction otherFaction, RelationType currentRelation)
		{
			var newRelationship = new Relationship(this, otherFaction, currentRelation);

			relationships.Add(otherFaction, newRelationship);

			return newRelationship;
		}
Пример #2
0
		public Relationship(Faction fromFaction, Faction toFaction, RelationType currentRelation)
		{
			this.fromFaction = fromFaction;
			this.toFaction = toFaction;

			fromFactionName = fromFaction.name;
			toFactionName = toFaction.name;

			this.currentRelation = currentRelation;
		}
Пример #3
0
		public GameObject buildUnit(Transform spawn, UnitBuildInstructions buildInstructions, Faction faction)
		{
			GameObject unit;

			if (buildInstructions.prefab != null)
				unit = GameObject.Instantiate(buildInstructions.prefab);
			else
				unit = GameObject.Instantiate(unitBuilds[buildInstructions.type]);

			var unitComponent = unit.GetComponent<BaseUnit>();
			unitComponent.InitializeUnit(faction, buildInstructions);

			return unit;
		}
Пример #4
0
		public void InitializeUnit(Faction unitFaction, UnitBuildInstructions template)
		{
			faction = unitFaction;

			_currentHealth = template.health;

			_buildInstructions = template;


			if (_currentHealth == 0)
				_currentHealth = 200;
			Globals.playfield.AddUnit(this);

			InitBehaviourTree();
		}
Пример #5
0
		private void Awake()
		{
			Globals.gameController = this;

			#region SetupAndroidScreen
			if (Screen.orientation == ScreenOrientation.Portrait ||
				Screen.orientation == ScreenOrientation.PortraitUpsideDown)
				Screen.orientation = ScreenOrientation.Landscape;
			
			Screen.orientation = ScreenOrientation.AutoRotation;

			Screen.autorotateToLandscapeLeft = true;
			Screen.autorotateToLandscapeRight = true;

			Screen.autorotateToPortrait = false;
			Screen.autorotateToPortraitUpsideDown = false;

			Screen.orientation = ScreenOrientation.AutoRotation;
			#endregion

			{
				var playerFaction = new PlayerFaction("Player Army")
				{
					controlType = ControlType.Player,
					teamColor = Color.cyan
				};

				var civilianFaction = new Faction("The Farmers")
				{
					controlType = ControlType.Civilian,
					teamColor = Color.green
				};

				var defenderFaction = new Faction("The Royal Army")
				{
					controlType = ControlType.King,
					teamColor = Color.yellow
				};

				playerFaction.DefineRelationshipTo(civilianFaction, RelationType.Prey);
				playerFaction.DefineRelationshipTo(defenderFaction, RelationType.Hostile);

				civilianFaction.DefineRelationshipTo(playerFaction, RelationType.Unknown);
				civilianFaction.DefineRelationshipTo(defenderFaction, RelationType.Friendly);

				defenderFaction.DefineRelationshipTo(playerFaction, RelationType.Hostile);
				defenderFaction.DefineRelationshipTo(civilianFaction, RelationType.Neutral);

				factions.Add(playerFaction);
				factions.Add(civilianFaction);
				factions.Add(defenderFaction);

#if UNITY_EDITOR
				foreach (var faction in factions)
				{
					if (faction != playerFaction)
						Assert.IsTrue(playerFaction.relationships.ContainsKey(faction));
					if (faction != civilianFaction)
						Assert.IsTrue(civilianFaction.relationships.ContainsKey(faction));
					if (faction != defenderFaction)
						Assert.IsTrue(defenderFaction.relationships.ContainsKey(faction));
				}
#endif

				localPlayerFaction = playerFaction;
				localPlayerFaction.availableUnits = availablePlayerUnits;
				Globals.playerFaction = playerFaction;
			}
		}