public static RandomAction CreateInstance(GameObject destination, int minTime, int maxTime) { RandomAction rt = destination.AddComponent <RandomAction>(); minimumTime = minTime; maximumTime = maxTime; return(rt); }
private void Awake() { renderer = GetComponent <SpriteRenderer>(); if (randomAnimationStartTime) { frame = Random.Range(0, sprites.Length); } sprites = idleAnimation; action = GetRandomAction(); AutoSetColor(); }
void Start() { mainCamera = Camera.main; rigidBody = gameObject.GetComponent <Rigidbody>(); rendererBall = gameObject.GetComponent <Renderer>(); sphereCollider = GetComponent <SphereCollider>(); sphereCollider.material.bounciness = 0.3f; sphereCollider.material.bounceCombine = PhysicMaterialCombine.Maximum; collSetup = sphereCollider.gameObject.AddComponent <ColliderSetup>(); initialPosition = transform.position; randomAction = RandomAction.CreateInstance(gameObject, 120, 300); randomAction.ActionAdd(ColorChange); }
private void Update() { if (respawnAt <= Time.time) { var gameArea = GameObject.Find("GameArea"); var gameAreaCollider = gameArea.GetComponent <Collider2D>(); var bounds = gameAreaCollider.bounds; var x = Random.Range(bounds.min.x, bounds.max.x); var y = Random.Range(bounds.min.y, bounds.max.y); var position = new Vector3(x, y, 0); renderer.transform.position = position; collected = false; sprites = idleAnimation; respawnAt = Time.time + respawnInterval; action = GetRandomAction(); AutoSetColor(); } }
void Start() { audio = GetComponent <AudioSource>(); randomAction = GetComponent <RandomAction>(); gm = GetComponent <GameMaster>(); }
private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e) { RLKeyPress keyPress = _rootConsole.Keyboard.GetKeyPress(); if (keyPress != null) { if (ActiveMenu) { foreach (IRlKeyOption rlko in PopupMenu.MenuItems) { if (keyPress.Key == rlko.Key) { rlko.Action(_currentCelestialObject); } } return; } if (keyPress.Key == RLKey.Up) { if (FuelCheck()) { return; } RandomAction.Go(); if (_currentSectorMap.SectorMap.GetCell(Player.X, Player.Y - 1).IsWalkable) { // Update the player position Player.Y--; Player.Fuel--; } else { ICelestialObject ce = CheckObject(Player.X, Player.Y - 1); if (ce != null) { _currentCelestialObject = ce; PopupMenu = new PopupMenu(ce.Name, ce.Menu.Options, 10, 10); ActiveMenu = true; } } } // Repeat for the other directions else if (keyPress.Key == RLKey.Down) { if (FuelCheck()) { return; } RandomAction.Go(); if (_currentSectorMap.SectorMap.GetCell(Player.X, Player.Y + 1).IsWalkable) { Player.Y++; Player.Fuel--; } else { ICelestialObject ce = CheckObject(Player.X, Player.Y + 1); if (ce != null) { _currentCelestialObject = ce; PopupMenu = new PopupMenu(ce.Name, ce.Menu.Options, 10, 10); ActiveMenu = true; } } } else if (keyPress.Key == RLKey.Left) { if (FuelCheck()) { return; } RandomAction.Go(); if (_currentSectorMap.SectorMap.GetCell(Player.X - 1, Player.Y).IsWalkable) { Player.X--; Player.Fuel--; } else { ICelestialObject ce = CheckObject(Player.X - 1, Player.Y); if (ce != null) { _currentCelestialObject = ce; PopupMenu = new PopupMenu(ce.Name, ce.Menu.Options, 10, 10); ActiveMenu = true; } } } else if (keyPress.Key == RLKey.Right) { if (FuelCheck()) { return; } RandomAction.Go(); if (_currentSectorMap.SectorMap.GetCell(Player.X + 1, Player.Y).IsWalkable) { Player.X++; Player.Fuel--; } else { ICelestialObject ce = CheckObject(Player.X + 1, Player.Y); if (ce != null) { _currentCelestialObject = ce; PopupMenu = new PopupMenu(ce.Name, ce.Menu.Options, 10, 10); ActiveMenu = true; } } } } }
public void TestMethod1() { var action = new RandomAction(); }