private static void AssignTeam(GameObject blob, TeamTag teamName) // TODO make less nested loops { blob.GetComponent <TaggedObject>().teamTag = teamName; SkinnedMeshRenderer[] models = blob.GetComponentsInChildren <SkinnedMeshRenderer>(); // TODO make material with certain name modifyable for (int i = 0; i < models.Length; i++) { if (models[i].gameObject.name == "Cube") { List <Material> materials = new List <Material>(); foreach (var material in models[i].materials) { Material localMaterial = material; if (material.name.Contains("Body")) { switch (teamName) { case TeamTag.Enemy: localMaterial = Resources.Load("TeamMaterials/Enemy") as Material; break; } } materials.Add(localMaterial); } models[i].materials = materials.ToArray(); } } }
public void showNums() { GameObject[] PlayerArray = GameObject.FindGameObjectsWithTag("Player"); for (int i = 0; i < PlayerArray.Length; i++) { TeamTag tag = PlayerArray[i].GetComponent <TeamSetup>().teamTag; bool temp = !TeamCount[tag].Contains(PlayerArray[i]); if (Vector3.Distance(transform.position, PlayerArray[i].transform.position) < radius) { if (temp) { TeamCount[tag].Add(PlayerArray[i]); } } else { if (!temp) { TeamCount[tag].Remove(PlayerArray[i]); } } } TeamTag tempTag = TeamTag.red; for (int i = 0; i < teamTextList.Length; i++) { teamTextList[i].text = TeamCount[tempTag].Count.ToString(); teamTextList[i].color = TeamSetup.returnColor(tempTag); tempTag++; } }
public RunAwayAction(GameObject blob) { this.blob = blob; blobMovement = blob.GetComponent <BlobMovement>(); teamTag = blob.GetComponent <TaggedObject>().teamTag; blobStats = blob.GetComponent <BlobStats>(); }
public void RemoveTeamControl(TeamTag teamTag) { var teamIndex = Team.GetTeamIndexFromTag(teamTag); teamControl[teamIndex] = false; floorImage.material = Map.Instance.GetTileMaterial(teamControl); }
void Update() { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Input.GetMouseButtonDown(0)) { if (Physics.Raycast(ray, out hit)) { if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Ground")) { GameObject go = Instantiate(playerPrefebs, hit.point + Vector3.up, Quaternion.identity); go.GetComponent <TeamSetup>().teamTag = precentTag; } if (hit.collider.gameObject.tag == "Player") { OccupyPoint.GetComponent <OccupationPos>().delePlayer(hit.collider.gameObject); DestroyImmediate(hit.collider.gameObject); } } } if (Input.GetKeyDown(KeyCode.R)) { precentTag = TeamTag.red; } if (Input.GetKeyDown(KeyCode.G)) { precentTag = TeamTag.green; } if (Input.GetKeyDown(KeyCode.B)) { precentTag = TeamTag.blue; } }
public void SetTeam(TeamTag tag) { SoldierInterface.Tag = tag; transform.parent.gameObject.tag = tag.ToString(); SelectInterface.ChangeColor(SoldierInterface.Tag); targetContrl = null; enemyTeamTag = SoldierInterface.Tag == TeamTag.BadGuy ? TeamTag.GoodGuy : TeamTag.BadGuy; }
public MeleeFightAction(GameObject blob) { this.blob = blob; blobMovement = blob.GetComponent <BlobMovement>(); blobAnimationController = blob.GetComponent <AnimationController>(); blobStats = blob.GetComponent <BlobStats>(); teamTag = blob.GetComponent <TaggedObject>().teamTag; blobAnimationController.OnKicked += DealDamage; }
private void Spawn(BlobStatsData blobStatsData, TeamTag teamTag, Vector3 blobPosition) { //CheckIfEnoughSpawnPoints(blobStatsData.Count, availableSpawnPoints.Count); GameObject blob = BlobInstantiator.GetBlobGameObject(blobStatsData, teamTag); blob.transform.localPosition = blobPosition; ObjectManager.GetInstance().AddObject(blob); }
public Partawn Emit( TeamTag teamTag, Vector2 location, float rotation, float speed, float dps, float life) { Partawn p = new Partawn( idSource++, teamTag, location, rotation, speed, dps, life); partawns.Add(p); return(p); }
public bool CheckCanBuild(TeamTag tag, BuildingType buildingType) { if (teamControl[Team.GetTeamIndexFromTag(tag)] == false || Building != null || resourceNodes.Count != 0) { return(false); } if (buildingType == BuildingType.None || ConstructionSite == null) { return(true); } return(ConstructionSite.Building.type == buildingType); }
private void AddTagWidget(TeamTag tag) { CheckButton button = new CheckButton(tag.Value == Team.LOCAL ? localTeam : visitorTeam ); button.Toggled += delegate(object sender, EventArgs e) { if (button.Active) { tags.Add(tag); } else tags.Remove(tag); }; dict.Add(tag, button); buttonsbox.PackStart(button, false, false, 0); button.ShowAll(); }
private void Awake() { animator = transform.parent.GetComponent <Animator>(); SoldierInterface = Soldier.GetComponent <ISoldier>(); AttackInterface = Attack.GetComponent <IAttackable>(); MoveInterface = Movement.GetComponent <IMovable>(); SelectInterface = Select.GetComponent <ISelectable>(); DamageInterface = Damage.GetComponent <IDamageable>(); WeaponInterface = Weapon.GetComponent <IWeapon>(); agent = transform.parent.GetComponent <NavMeshAgent>(); myTransform = transform.parent.GetComponent <Transform>(); enemyTeamTag = SoldierInterface.Tag == TeamTag.BadGuy ? TeamTag.GoodGuy : TeamTag.BadGuy; }
public static Color returnColor(TeamTag tag) { switch (tag) { case TeamTag.red: return(Color.red); break; case TeamTag.blue: return(Color.blue); break; case TeamTag.green: return(Color.green); break; default: return(Color.white); } }
public List <TaggedObject> GetAllTeammates(TeamTag teamTag) { List <TaggedObject> taggedObjects = new List <TaggedObject>(); foreach (var taggedObject in TaggedObjects) { if (taggedObject.teamTag == teamTag) { taggedObjects.Add(taggedObject); } } return(taggedObjects); }
void Awake() { aiUnit = GetComponent <CharacterControl> (); animator = GetComponentInChildren <Animator> (); pandaTree = GetComponent <PandaBehaviour> (); team = aiUnit.CharacterData.Team; LastGetHitTime = Mathf.NegativeInfinity; LastTargetAttackTime = Mathf.NegativeInfinity; LastTargetExecuteTime = Mathf.NegativeInfinity; LastTargetDodgeTime = Mathf.NegativeInfinity; LastTargetGuardTime = Mathf.NegativeInfinity; enemyTarget = null; AIAgentManager.Instance.TotalAIAgent.Add(this); }
public void Spawn(TeamTag team, Vector3 v) { Entity entity = entityManager.CreateEntity( team == TeamTag.Alpha ? alphaArchetype : betaArchetype); entities.Add(entity); entityManager.SetComponentData( entity, new Translation { Value = new float3(v.x, v.y, v.z) }); entityManager.SetComponentData( entity, new Scale { Value = scale }); entityManager.SetComponentData( entity, new Parent { Value = parentEntity }); entityManager.SetComponentData( entity, new Pawn { Team = team, Health = 100.0f }); Material material = null; if (team == TeamTag.Alpha) { material = rubyMaterial; } else { material = sapphireMaterial; } entityManager.SetSharedComponentData( entity, new RenderMesh { mesh = mesh, material = material }); }
private void Update() { OccupyRate = Mathf.Clamp(OccupyRate, 0, 100); if (OccupyRate == 0) { precentOccTeam = lastOccTeam; } OccupySlider.value = OccupyRate / 100f; SliderBack.GetComponent <Image>().color = TeamSetup.returnColor(precentOccTeam); drawCircle(); showNums(); if ((Time.time - prevTime) > 1) { prevTime = Time.time; int InAreaTeam = 0; int TeamNums = 0; TeamTag InAreaTeamName = TeamTag.red; TeamTag tempTag = TeamTag.red; for (int i = 0; i < TeamCount.Count; i++) { if (TeamCount[tempTag].Count != 0) { InAreaTeam++; if (TeamCount[tempTag].Count > TeamNums) { TeamNums = TeamCount[tempTag].Count; } InAreaTeamName = tempTag; } tempTag++; } if (InAreaTeam == 1) { lastOccTeam = InAreaTeamName; if (precentOccTeam != InAreaTeamName) { OccupyRate -= teamNumAddRate[TeamNums]; } else { OccupyRate += teamNumAddRate[TeamNums]; } } } }
private void AddTagWidget(TeamTag tag) { CheckButton button = new CheckButton(tag.Value == Team.LOCAL ? localTeam : visitorTeam); button.Toggled += delegate(object sender, EventArgs e) { if (button.Active) { tags.Add(tag); } else { tags.Remove(tag); } }; dict.Add(tag, button); buttonsbox.PackStart(button, false, false, 0); button.ShowAll(); }
public Partawn( int id, TeamTag teamTag, Vector2 location, float rotation, float speed, float dps, float life) { this.id = id; this.teamTag = teamTag; this.location = location; this.rotation = rotation; this.speed = speed; this.dps = dps; this.initialLife = life; this.life = life; var rad = Mathf.Deg2Rad * rotation; direction = new Vector2(Mathf.Cos(rad), Mathf.Sin(rad)); }
public List <TaggedObject> GetAllEnemies(TeamTag ownTeamTag) { List <TaggedObject> taggedObjects = new List <TaggedObject>(); List <TeamTag> teamTags = Enum.GetValues(typeof(TeamTag)).Cast <TeamTag>().ToList(); teamTags.Remove(ownTeamTag); teamTags.Remove(TeamTag.None); foreach (var taggedObject in TaggedObjects) { if (teamTags.Contains(taggedObject.teamTag)) { taggedObjects.Add(taggedObject); } } return(taggedObjects); }
public static GameObject GetBlobGameObject(BlobStatsData blobStats, TeamTag teamTag) { GameObject blob = null; switch (blobStats.blobType) { case BlobType.Survivor: blob = GameObject.Instantiate(Resources.Load("Blob") as GameObject); break; case BlobType.Fighter: blob = GameObject.Instantiate(Resources.Load("Fighter") as GameObject); break; } blob.GetComponent <BlobStats>().stats = blobStats; AssignTeam(blob, teamTag); return(blob); }
public Entity PlayerInstantiate(int id) { var entityManager = World.Active.EntityManager; _playerEntity = entityManager.Instantiate(_playerPrefabEntity); var teamTag = new TeamTag() { Id = id, }; entityManager.SetComponentData(_playerEntity, teamTag); var tmpRenderer = entityManager.GetSharedComponentData <RenderMesh>(_playerEntity); tmpRenderer.material = PlayerMaterial; entityManager.SetSharedComponentData(_playerEntity, tmpRenderer); return(_playerEntity); }
private Entity instantiate(Entity template) { var entityManager = World.Active.EntityManager; var entity = entityManager.Instantiate(template); entityManager.SetComponentData( entity, new Translation { Value = transform.TransformPoint(0, 0, 0) } ); entityManager.SetComponentData( entity, new Rotation { Value = transform.rotation } ); TeamTag tag = unitDef.team.toComponent(); entityManager.SetComponentData( entity, new PhysicsVelocity { Linear = unitDef.initialVelocity } ); tag.AssignToEntity(entityManager, entity); var baseRotation = entityManager.GetComponentData <Rotation>(entity); foreach (TurretInfo turret in unitDef.turretPositionInfo) { Entity turretEntity = TurretInstantiator.instantiate(unitDef.team, turret, baseRotation); entityManager.AddComponent(turretEntity, typeof(LocalToParent)); entityManager.AddComponent(turretEntity, typeof(Parent)); entityManager.SetComponentData <Parent>(turretEntity, new Parent { Value = entity }); } return(entity); }
public void ChangeColor(TeamTag tag) { spriteIndicator.color = tag == TeamTag.BadGuy ? new Color(255f / 255f, 96f / 255f, 96f / 255f, 159f / 255f) : new Color(175f / 255f, 96f / 236f, 183f / 255f, 159f / 255f); }
// IMPROVE: Not sure this is the best way. public Team GetTeam(TeamTag tag) => tag == TeamTag.red ? redTeam : greenTeam;
private void JoinUser(string userName, TeamTag teamTag) { if (isSessionRunning == false && teamTag != TeamTag.None) { if (greenTeamPlayers.Contains(userName) && teamTag == TeamTag.red) { greenTeamPlayers.Remove(userName); redTeamPlayers.Add(userName); joinUI.UpdatePlayers(greenTeamPlayers, redTeamPlayers); return; } if (redTeamPlayers.Contains(userName) && teamTag == TeamTag.green) { redTeamPlayers.Remove(userName); greenTeamPlayers.Add(userName); joinUI.UpdatePlayers(greenTeamPlayers, redTeamPlayers); return; } } if (greenTeamPlayers.Contains(userName) || redTeamPlayers.Contains(userName) || (greenTeamPlayers.Count == maxTeamSize && redTeamPlayers.Count == maxTeamSize)) { return; } if (teamTag == TeamTag.None) { if (greenTeamPlayers.Count > redTeamPlayers.Count) { teamTag = TeamTag.red; } else if (greenTeamPlayers.Count == redTeamPlayers.Count) { var rnd = Random.Range(0, 2); teamTag = rnd == 1 ? TeamTag.green : TeamTag.red; } else { teamTag = TeamTag.green; } } var playerTeam = teamTag == TeamTag.green ? greenTeam : redTeam; Debug.Log($"User joining {userName} to {teamTag.ToString()}."); if (teamTag == TeamTag.green) { greenTeamPlayers.Add(userName); } else { redTeamPlayers.Add(userName); } if (isSessionRunning) { playerTeam.SwapBotForPlayer(userName); } else { joinUI.UpdatePlayers(greenTeamPlayers, redTeamPlayers); } }
void UpdateStats(Project project) { catStats.Clear(); foreach (Category cat in project.Categories) { CategoryStats stats; List<Play> plays; int localTeamCount, visitorTeamCount; plays = project.PlaysInCategory (cat); CountPlaysInTeam(plays, out localTeamCount, out visitorTeamCount); stats = new CategoryStats(cat.Name, plays.Count, localTeamCount, visitorTeamCount); catStats.Add (stats); foreach (ISubCategory subcat in cat.SubCategories) { SubCategoryStat subcatStat; if (subcat is PlayerSubCategory) continue; subcatStat = new SubCategoryStat(subcat.Name); stats.AddSubcatStat(subcatStat); if (subcat is TagSubCategory) { foreach (string option in subcat.ElementsDesc()) { List<Play> subcatPlays; StringTag tag; tag = new StringTag{SubCategory=subcat, Value=option}; subcatPlays = plays.Where(p => p.Tags.Tags.Contains(tag)).ToList(); GetSubcategoryStats(subcatPlays, subcatStat, option, stats.TotalCount, out localTeamCount, out visitorTeamCount); GetPlayersStats(project, subcatPlays, option, subcatStat, cat); } } if (subcat is TeamSubCategory) { List<Team> teams = new List<Team>(); teams.Add(Team.LOCAL); teams.Add(Team.VISITOR); foreach (Team team in teams) { List<Play> subcatPlays; TeamTag tag; tag = new TeamTag{SubCategory=subcat, Value=team}; subcatPlays = plays.Where(p => p.Teams.Tags.Contains(tag)).ToList(); GetSubcategoryStats(subcatPlays, subcatStat, team.ToString(), stats.TotalCount, out localTeamCount, out visitorTeamCount); } } } } }
public static Entity instantiate(Team team, TurretInfo info, Rotation?parentRotation) { var entityManager = World.Active.EntityManager; var definition = info.definition; instantiateData(definition); var turretBaseEntity = entityManager.Instantiate(entities[definition.basePrefab.GetHashCode()]); entityManager.SetComponentData( turretBaseEntity, new Translation { Value = info.position } ); var rotation = quaternion.EulerXYZ(math.radians(info.facing.x), math.radians(info.facing.y), math.radians(info.facing.z)); entityManager.SetComponentData( turretBaseEntity, new Rotation { Value = rotation } ); var gun = definition.gun; var turretGunEntity = entityManager.Instantiate(entities[gun.prefab.GetHashCode()]); TeamTag tag = team.toComponent(); tag.AssignToEntity(entityManager, turretGunEntity); entityManager.AddComponent(turretGunEntity, typeof(LocalToParent)); entityManager.AddComponent(turretGunEntity, typeof(Parent)); entityManager.SetComponentData <Parent>( turretGunEntity, new Parent { Value = turretBaseEntity } ); entityManager.SetComponentData( turretGunEntity, new Translation { Value = definition.gunOffset } ); entityManager.SetComponentData( turretGunEntity, new Rotation { Value = rotation } ); entityManager.AddComponentData(turretGunEntity, new GunData { projectileEntity = entities[gun.projectile.prefab.GetHashCode()], projectileOffset = gun.barrelOffset, muzzleFlashEffect = gun.muzzleEffectPrefab.GetHashCode(), projectileVelocity = gun.muzzleVelocity, reloadInterval = gun.reloadInterval, fireInterval = gun.fireInterval, shotsPerReload = gun.shotsPerReload, shotDeviation = math.radians(gun.shotDeviationDegrees), maximumPitchDelta = math.radians(gun.maximumPitchDeltaDegrees), rotationSpeed = 1f, pitchSpeed = 5f, neutralRotation = rotation, parentRotation = parentRotation, }); entityManager.AddComponentData(turretGunEntity, new GunState { currentFireInterval = 0, currentReloadInterval = 0, shotsRemaining = 4, currentPitch = math.PI / 2f, targetPitchDelta = math.PI / 2f, }); return(turretBaseEntity); }
public static int GetTeamIndexFromTag(TeamTag tag) => (int)tag - 1;
void UpdateStats(Project project) { catStats.Clear(); Field = project.Categories.FieldBackground; HalfField = project.Categories.HalfFieldBackground; Goal = project.Categories.GoalBackground; foreach (Category cat in project.Categories) { CategoryStats stats; List <Play> plays, homePlays, awayPlays; int localTeamCount, visitorTeamCount; plays = project.PlaysInCategory(cat); homePlays = plays.Where(p => p.Team == Team.LOCAL || p.Team == Team.BOTH).ToList(); awayPlays = plays.Where(p => p.Team == Team.VISITOR || p.Team == Team.BOTH).ToList(); stats = new CategoryStats(cat, plays.Count, homePlays.Count(), awayPlays.Count()); /* Fill zonal tagging stats */ stats.FieldCoordinates = plays.Select(p => p.FieldPosition).Where(p => p != null).ToList(); stats.HalfFieldCoordinates = plays.Select(p => p.HalfFieldPosition).Where(p => p != null).ToList(); stats.GoalCoordinates = plays.Select(p => p.GoalPosition).Where(p => p != null).ToList(); stats.HomeFieldCoordinates = homePlays.Select(p => p.FieldPosition).Where(p => p != null).ToList(); stats.HomeHalfFieldCoordinates = homePlays.Select(p => p.HalfFieldPosition).Where(p => p != null).ToList(); stats.HomeGoalCoordinates = homePlays.Select(p => p.GoalPosition).Where(p => p != null).ToList(); stats.AwayFieldCoordinates = awayPlays.Select(p => p.FieldPosition).Where(p => p != null).ToList(); stats.AwayHalfFieldCoordinates = awayPlays.Select(p => p.HalfFieldPosition).Where(p => p != null).ToList(); stats.AwayGoalCoordinates = awayPlays.Select(p => p.GoalPosition).Where(p => p != null).ToList(); catStats.Add(stats); foreach (ISubCategory subcat in cat.SubCategories) { SubCategoryStat subcatStat; if (subcat is PlayerSubCategory) { continue; } subcatStat = new SubCategoryStat(subcat); stats.AddSubcatStat(subcatStat); if (subcat is TagSubCategory) { foreach (string option in subcat.ElementsDesc()) { List <Play> subcatPlays; StringTag tag; tag = new StringTag { SubCategory = subcat, Value = option }; subcatPlays = plays.Where(p => p.Tags.Tags.Contains(tag)).ToList(); GetSubcategoryStats(subcatPlays, subcatStat, option, stats.TotalCount, out localTeamCount, out visitorTeamCount); GetPlayersStats(project, subcatPlays, option, subcatStat, cat); } } if (subcat is TeamSubCategory) { List <Team> teams = new List <Team>(); teams.Add(Team.LOCAL); teams.Add(Team.VISITOR); foreach (Team team in teams) { List <Play> subcatPlays; TeamTag tag; tag = new TeamTag { SubCategory = subcat, Value = team }; subcatPlays = plays.Where(p => p.Teams.Tags.Contains(tag)).ToList(); GetSubcategoryStats(subcatPlays, subcatStat, team.ToString(), stats.TotalCount, out localTeamCount, out visitorTeamCount); } } } } }