private void AddComponent(GameObject gameObjectTotem, TotemInstantiatorConfig totem) { if (HasAddedTotemComponents (gameObjectTotem, totem)) { Totem totemObject = gameObjectTotem.GetComponent<Totem> (); totemObject.SetUp (totem, validStartPoints); AddTotemBehaviours(gameObjectTotem, totem); } }
private void AddTotemBehaviours(GameObject gameObjectTotem, TotemInstantiatorConfig totem) { foreach (TotemBehaviours behavioursTypes in totem.BehavioursTypes) { if(behavioursTypes == TotemBehaviours.Explosive) gameObjectTotem.AddComponent<TotemExplosive> (); else if(behavioursTypes == TotemBehaviours.HoleFiller) gameObjectTotem.AddComponent<TotemHoleFiller> (); else if(behavioursTypes == TotemBehaviours.Phantom) gameObjectTotem.AddComponent<TotemPhantom> (); } }
private bool HasAddedTotemComponents(GameObject gameObjectTotem, TotemInstantiatorConfig totem) { if (totem.Type == TotemType.Square) gameObjectTotem.AddComponent<SquareTotem> (); else if (totem.Type == TotemType.Triangle) gameObjectTotem.AddComponent<TriangleTotem> (); else if (totem.Type == TotemType.Sphere) gameObjectTotem.AddComponent<SphereTotem> (); else return false; return true; }
private void InitializeComponents(GameObject gameObjectTotem, TotemInstantiatorConfig totem, List<Node> points, Transform positionsToSnap) { MapObject mapObject = gameObjectTotem.GetComponent<MapObject> (); Transform startPosition = CreateStartPosition (points, totem.PositionToAdd); mapObject.SetStartPosition (startPosition); AddComponent (gameObjectTotem, totem); }
public void SetUp(TotemInstantiatorConfig totem, List<int> validStartPoints) { if (validTypes.Contains (totem.Type)) { this.totem = totem; this.validStartPoints = validStartPoints; GameManagerForStates.StartedGame += OnStartedGame; controllerToStop.CollidedWithTotem += OnCrashWithOtherCollider; positionToGo = totem.PositionToGo; } }