private void OnCollisionEnter(Collision collision) { var ingredient = collision.gameObject.GetComponent <PickableObject>(); if (ingredient && !ingredient.IsHeld()) { var ingredientType = collision.gameObject.GetComponentInChildren <IngredientType>(); var thrower = ingredient.ThrownIntentionallyBy(); if (thrower && thrower.Equals(m_owner) && ingredientType && ShouldAcceptIngredient(ingredientType.m_type)) { OnCollectIngredient(); m_storedIngredient = ingredientType.m_type; Destroy(collision.gameObject); var nextMinigame = Random.Range(0, m_miniGames.Length); m_miniGames[nextMinigame].StartMinigame(); } else { var burst = Instantiate(HitPrefab, collision.GetContact(0).point, Quaternion.LookRotation(collision.GetContact(0).normal)); var burstMat = burst.gameObject.GetComponentInChildren <ParticleSystemRenderer>().material; var trailMat = burst.gameObject.GetComponentInChildren <ParticleSystemRenderer>().trailMaterial; burstMat.SetColor("_EmissionColor", ColorsManager.Get().PlayerForceFieldColors[m_owner.ID]); trailMat.SetColor("_EmissionColor", ColorsManager.Get().PlayerForceFieldColors[m_owner.ID]); StartCoroutine(DestroyWhenComplete(burst)); } ingredient.ResetAimAssist(); } }
public override IEnumerator SpellImplementation() { var targetPlayer = m_mainManager.GetPlayerById(_TargetedPlayer.id); var gift = Instantiate(m_giftPrefab, targetPlayer.transform.position + new Vector3(0, 2, -2), new Quaternion(0, 0, 0, 0)); var giftComponent = gift.GetComponent <Gift>(); giftComponent.SetIngredientType(Ingredient.NOT_AN_INGREDIENT); giftComponent.SetContents(m_bombPrefab); giftComponent.SetColor(ColorsManager.Get().PlayerGiftColors[_TargetedPlayer.id]); giftComponent.SetFollowTarget(targetPlayer.transform); yield return(null); }
public void OnPotionComplete(ARecipeManager cauldron) { var potionObj = Instantiate(m_potionPrefab, cauldron.transform.position + new Vector3(0, 3, 0), Quaternion.identity); var potion = potionObj.GetComponent <FlyingPotion>(); //Set color var liquidColor = ColorsManager.Get().CauldronLiquidColors[cauldron.Owner.ID]; potion.SetColor(liquidColor); //Set Destination potion.SetDestination(m_audienceInterface); }
public void Get() { var man = new ColorsManager(-100, 100); Assert.AreEqual(ColorsManager.Red, man.Get(1000)); Assert.AreEqual(ColorsManager.DarkBlue, man.Get(-100)); Assert.AreEqual(new Color3(0, 238.1, 254.15), man.Get(-1)); Assert.AreEqual(ColorsManager.Blue, man.Get(0)); Assert.AreEqual(ColorsManager.Red, man.Get(100)); man = new ColorsManager(0, 100, 50); Assert.AreEqual(ColorsManager.Blue, man.Get(50)); Assert.AreEqual(new Color3(0, 145, 212.5), man.Get(25)); Assert.AreEqual(ColorsManager.DarkBlue, man.Get(0)); Assert.AreEqual(ColorsManager.Red, man.Get(100)); man = new ColorsManager(-200, 100, 50); Assert.AreEqual(ColorsManager.Blue, man.Get(50)); Assert.AreEqual(ColorsManager.DarkBlue, man.Get(-200)); Assert.AreEqual(ColorsManager.Red, man.Get(100)); }
void InitHUD() { var playersHUDZone = GameObject.FindGameObjectWithTag(Tags.PLAYERS_HUD_ZONE); var instance = Instantiate(_PlayerHUDPrefab, playersHUDZone.transform); Owner.PlayerHUD = instance.GetComponent <PlayerHUD>(); Owner.PlayerHUD.Manager = Owner; Owner.PlayerHUD.OwnerId = Owner.ID; var backdrop = instance.transform.Find("Organizer"); var rect = backdrop.GetComponent <Image>(); rect.color = ColorsManager.Get().CauldronLiquidColors[Owner.ID]; }
// Override liquid and bubbles colors per player protected override void OnSetOwner(PlayerManager owner) { var liquid = transform.Find("Liquid"); var matOverrideLiquid = liquid.gameObject.AddComponent <gfx.MaterialOverride>(); var liquidColor = ColorsManager.Get().CauldronLiquidColors[owner.ID]; matOverrideLiquid.Entries.Add(new gfx.MaterialOverride.Entry("_Color", liquidColor)); matOverrideLiquid.Apply(); var bubbles = transform.Find("Bubbles"); var matOverrideBubbles = bubbles.gameObject.AddComponent <gfx.MaterialOverride>(); var bubblesColor = ColorsManager.Get().CauldronBubblesColors[owner.ID]; matOverrideBubbles.Entries.Add(new gfx.MaterialOverride.Entry("_EmissionColor", bubblesColor)); matOverrideBubbles.Apply(); }
private void SetBorderColor() { var newLeaderId = GetLeaderId(); if (newLeaderId != m_currentLeaderId) { BordersStartColor = BordersMaterial.color; BordersEndColor = ColorsManager.Get().PlayerBorderColors[newLeaderId]; BordersPlaying = true; BordersStartTime = Time.time; PlayersInstances[newLeaderId].PlayerHUD.GetComponent <GrowShrinkEffect>().Grow(); if (m_currentLeaderId != -1) { PlayersInstances[m_currentLeaderId].PlayerHUD.GetComponent <GrowShrinkEffect>().Shrink(); } m_currentLeaderId = newLeaderId; } }
PlayerManager InitPlayer() { var player = Instantiate( OwnerId % 2 == 0 ? _MalePrefab : _FemalePrefab, PlayerSpawnPosition, Quaternion.identity); player.transform.forward = -PlayerSpawnPosition; player.transform.SetParent(transform); Owner = player.GetComponent <PlayerManager>(); Owner.ID = OwnerId; Owner.Name = Players.Info[OwnerId].Name; Owner.Texture = ColorsManager.Get().PlayerColorTextures[Owner.ID]; var normalTex = ColorsManager.Get().PlayerNormalTextures[Owner.ID]; if (normalTex != null) { Owner.NormalTexture = normalTex; } var occlusionTex = ColorsManager.Get().PlayerOcclusionTextures[Owner.ID]; if (occlusionTex != null) { Owner.OcclusionTexture = occlusionTex; } var roughnessTex = ColorsManager.Get().PlayerRoughnessTextures[Owner.ID]; if (roughnessTex != null) { Owner.RoughnessTexture = roughnessTex; } Owner.CompletedPotionCount = 0; Owner.CollectedIngredientCount = 0; return(Owner); }
private void SetAvatars() { var avatarContainer = GameObject.Find("Avatars").transform; int rank = 0; int count = 0; bool allCharactersHandled = false; for (int i = 0; i < avatarContainer.childCount; i++) { var a = avatarContainer.GetChild(i); if (!allCharactersHandled) { //Set color and correct model, ignore hair renderers SkinnedMeshRenderer[] tempRenderers = a.GetComponentsInChildren <SkinnedMeshRenderer>(); SkinnedMeshRenderer[] skinRenderers = new SkinnedMeshRenderer[2]; int j = 0; foreach (var r in tempRenderers) { if (r.gameObject.layer != 15) { skinRenderers[j] = r; j++; } } var id = m_finalRankings[rank][count].ID; var model = skinRenderers[id % 2]; model.material.mainTexture = ColorsManager.Get().PlayerColorTextures[id]; var temp = skinRenderers[(id + 1) % 2].transform; while (temp.parent != null) { if (temp.parent.tag == Tags.PLAYER_TAG) { temp.parent.gameObject.SetActive(false); break; } temp = temp.parent.transform; } //Scale based on rank a.gameObject.transform.localScale *= (MaxNumPlayers + 0.5f - rank) / 2.0f; //add 0.5 so the player in 4th is shrunk, not set to 0x scale a.gameObject.transform.position = new Vector3(0, 0, i * 60 - 240); if (rank == 0) { var anim = model.GetComponentInParent <MenuModelAnims>(); anim.Carry(); var trophy = a.transform.Find("trophy"); trophy.gameObject.SetActive(true); } else if (rank == m_finalRankings.Count - 1) { var anim = model.GetComponentInParent <MenuModelAnims>(); anim.Dizzy(); } count++; if (count >= m_finalRankings[rank].Count) { count = 0; rank++; if (rank >= m_finalRankings.Count) { allCharactersHandled = true; } } } else { a.gameObject.SetActive(false); } } }
public void SetReadyActive() { RegularHUD.SetActive(false); ReadyPanel.SetActive(true); ReadyPanelMessage.color = ColorsManager.Get().PlayerMeshColors[Manager.ID]; }
/// <summary> /// Render state /// </summary> /// <param name="time"><see cref="GameTime"/></param> public override void Render(GameTime time) { DH.RenderScene(_gameplayScene, _camera, () => { foreach (WorldTile tile in _level.Map) { if (!tile.IsWall) { float distance = (float)Math.Sqrt(Math.Pow(tile.DisplayX - _player.X, 2) + Math.Pow(tile.DisplayY - _player.Y, 2)); float percentage = 1 - (distance < 350 ? 0 : (distance - 350) / 700); DH.Raw(_content.TEXGround.Texture, tile.DisplayX - 16, tile.DisplayY - 16, color: ColorsManager.Get(percentage)); } } if (_config.DebugMode) { foreach (WorldTile tile in _level.Map) { if (tile.Collisions.Contains(CollisionType.Left)) { DH.Line(tile.DisplayX, tile.DisplayY, tile.DisplayX, tile.DisplayY + tile.Size, 8, Color.Red); } if (tile.Collisions.Contains(CollisionType.Right)) { DH.Line(tile.DisplayX + tile.Size, tile.DisplayY, tile.DisplayX + tile.Size, tile.DisplayY + tile.Size, 8, Color.Red); } if (tile.Collisions.Contains(CollisionType.Top)) { DH.Line(tile.DisplayX, tile.DisplayY, tile.DisplayX + tile.Size, tile.DisplayY, 8, Color.Red); } if (tile.Collisions.Contains(CollisionType.Bottom)) { DH.Line(tile.DisplayX, tile.DisplayY + tile.Size, tile.DisplayX + tile.Size, tile.DisplayY + tile.Size, 8, Color.Red); } } } _player.Display(time); }); DH.RenderScene(Scene, () => { DH.Scene(_gameplayScene); DH.Text(_content.GetFont( ), _player.Name, 15, 15, false); // Mini-map UH.Loops(_level.Width, _level.Height, (x, y) => { if (!_level.Map[y * _level.Width + x].IsWall) { DH.Raw(_content.Pixel, _config.ViewWidth - 16 - _level.Width * 4 + x * 4, _config.ViewHeight - 16 - _level.Height * 4 + y * 4, 4, 4, (_player.OnMapX == x && _player.OnMapY == y ? Color.Red : Color.Gray) * .5f ); } }); if (_config.DebugMode) { DH.Text(_debugFont, $"{(int)(1 / time.ElapsedGameTime.TotalSeconds)} FPS", _config.WindowWidth - 10, 10, false, ColorsManager.DarkGray, AlignType.RT); DH.Text(_debugFont, $"Mouse ({_input.MouseX}, {_input.MouseY})", _config.WindowWidth - 10, 25, false, ColorsManager.DarkGray, AlignType.RT); DH.Text(_debugFont, $"Player ({_player.X:0.0}, {_player.Y:0.0}) ({_player.OnMapX}, {_player.OnMapY})", _config.WindowWidth - 10, 40, false, ColorsManager.DarkGray, AlignType.RT); DH.Text(_debugFont, $"Camera ({_camera.Target.X:0.0}, {_camera.Target.Y:0.0})", _config.WindowWidth - 10, 55, false, ColorsManager.DarkGray, AlignType.RT); DH.Text(_debugFont, $"Scale {_camera.Scale:0.00}x", _config.WindowWidth - 10, 70, false, ColorsManager.DarkGray, AlignType.RT); DH.Line(0, _config.WindowHeight / 2, _config.WindowWidth, _config.WindowHeight / 2, 1, ColorsManager.DarkestGray * .5f); DH.Line(_config.WindowWidth / 2, 0, _config.WindowWidth / 2, _config.WindowHeight, 1, ColorsManager.DarkestGray * .5f); } }); }