public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { if (!string.IsNullOrEmpty(toState)) { ((Entity)behaviour).AISetState(toState); } }
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { Entity ai = (Entity)behaviour; PlanetAttach pa = ai.planetAttach; pa.maxVelocity = velocity; }
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { CameraController.instance.mode = mode; if (attachToPath.Length > 0) { GameObject go = ((SceneController)behaviour).SearchObject(attachToPath); if (go != null) { CameraController.instance.attach = go.transform; } else { Debug.LogWarning("Path not found: " + attachToPath); } } else if (attachToWaypoint.Length > 0) { Transform t = WaypointManager.instance.GetWaypoint(attachToWaypoint); if (t != null) { CameraController.instance.attach = t; } else { Debug.LogWarning("Can't find waypoint: " + attachToWaypoint); } } if (immediate) { CameraController.instance.CancelMove(); } }
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { Entity ai = (Entity)behaviour; PlanetAttach pa = ai.planetAttach; AIState aiState = (AIState)state; if (accel > 0) { if (usePlayerDir) { Player player = SceneLevel.instance.player; aiState.curPlanetDir = pa.GetDirTo(player.planetAttach, horizontalOnly); } else if (!useDir) { aiState.curPlanetDir = Util.Vector2DRot(new Vector2(1, 0), angle * Mathf.Deg2Rad); } pa.accel = aiState.curPlanetDir * accel; } else { pa.accel = Vector2.zero; } }
public void Start(MonoBehaviour behaviour, Sequencer.StateInstance stateData, string stateName) { if (stateName == null) { stateName = sequenceDefaultState; } mCurState = stateName; if (!string.IsNullOrEmpty(stateName)) { if (mSequences != null) { Sequencer seq; if (mSequences.TryGetValue(stateName, out seq)) { behaviour.StartCoroutine(seq.Go(stateData, behaviour)); } else { Debug.LogError("State not found: " + stateName, behaviour); } } } }
public override bool Update(MonoBehaviour behaviour, Sequencer.StateInstance state) { bool done = true; if (followPlayer && !state.IsDelayReached(followPlayerDuration)) { Entity ai = (Entity)behaviour; PlanetAttach pa = ai.planetAttach; AIState aiState = (AIState)state; Player player = SceneLevel.instance.player; aiState.curPlanetDir = pa.GetDirTo(player.planetAttach, followPlayerHorizontal); if (followPlayerHorizontal) { pa.velocity = new Vector2(Mathf.Abs(pa.velocity.x) * aiState.curPlanetDir.x, pa.velocity.y); } else { pa.velocity = aiState.curPlanetDir * pa.velocity.magnitude; } done = false; } return(done); }
public Entity.Action actOnLand = Entity.Action.idle; //set to none or NumAction to keep jump state public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { Entity ai = (Entity)behaviour; PlanetAttach pa = ai.planetAttach; pa.Jump(speedMin < speedMax ? Random.Range(speedMin, speedMax) : speedMin); ai.action = Entity.Action.jump; }
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { Entity ai = (Entity)behaviour; PlanetAttach pa = ai.planetAttach; Player player = SceneLevel.instance.player; ((AIState)state).curPlanetDir = pa.GetDirTo(player.planetAttach, horizontalOnly); }
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { state.counter = 0; Player p = ((SceneLevel)behaviour).player; p.throwCallback = delegate(Player player) { state.counter = 1; }; }
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { SceneLevel.instance.IncWave(); HUDAnnounce announce = UIManager.instance.hud.announce; announce.state = HUDAnnounce.State.Blink; announce.message = isBossAnnounce ? bossString : SceneLevel.instance.GetWaveString(); announce.color = Color.white; state.counter = 0; }
public override bool Update(MonoBehaviour behaviour, Sequencer.StateInstance state) { SceneController.StateData dat = (SceneController.StateData)state; bool done = true; if (dat.entity != null) { done = dat.entity.action == action; } return(done); }
public override bool Update(MonoBehaviour behaviour, Sequencer.StateInstance state) { Entity ai = (Entity)behaviour; PlanetAttach pa = ai.planetAttach; bool done = pa.isGround; if (done && actOnLand != Entity.Action.none) { ai.action = actOnLand; } return(pa.isGround); }
public override bool Update(MonoBehaviour behaviour, Sequencer.StateInstance state) { bool done = true; Entity e = ((SceneController.StateData)state).entity; if (e != null) { e.SendMessage("OnSceneCounterCheck", state, SendMessageOptions.RequireReceiver); done = state.counter == counter; } return(done); }
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { if (entityPath.Length > 0) { GameObject go = ((SceneController)behaviour).SearchObject(entityPath); if (go != null) { go.SendMessage("OnSceneActivate", activate, SendMessageOptions.DontRequireReceiver); } else { Debug.LogWarning("Path not found: " + entityPath); } } }
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance aiState) { HUDAnnounce ha = UIManager.instance.hud.announce; ha.state = state; if (state != HUDAnnounce.State.None) { if ((state != HUDAnnounce.State.FadeOut && state != HUDAnnounce.State.FadeScaleOut) || message.Length > 0) { ha.color = new Color(((float)colorR) / 255.0f, ((float)colorG) / 255.0f, ((float)colorB) / 255.0f); ha.message = message; } } }
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { SceneLevel sl = SceneLevel.instance; Player player = sl.player; Transform t = EntityManager.instance.Spawn(type, name, null, null, useFX); if (t != null) { Vector2 playerPos = player.planetAttach.planetPos; Vector2 pos = sl.planet.body.ConvertToWorldPos(new Vector2(playerPos.x + x, playerPos.y + y)); t.position = new Vector3(pos.x, pos.y, t.position.z); t.GetComponentInChildren <PlanetAttachStatic>().RefreshPos(); } }
public override bool Update(MonoBehaviour behaviour, Sequencer.StateInstance state) { HUDAnnounce announce = UIManager.instance.hud.announce; bool isDone = false; switch ((State)state.counter) { case State.AnnounceWave: if (state.IsDelayReached(waveDelay)) { if (isBossAnnounce) { announce.state = HUDAnnounce.State.None; isDone = true; } else { announce.state = HUDAnnounce.State.Display; announce.message = goString; state.startTime = Time.time; state.counter++; } } break; case State.AnnounceGo: if (state.IsDelayReached(waveDelay)) { announce.state = HUDAnnounce.State.FadeScaleOut; state.counter++; } break; case State.AnnounceWaitEnd: isDone = announce.state == HUDAnnounce.State.None; break; } return(isDone); }
public bool fromScene = false; //use the entire scene for search, otherwise, just in entities public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { if (type.Length > 0) { System.Type theType = System.Type.GetType(type); Component[] comps; if (fromScene) { comps = ((SceneController)behaviour).GetComponentsInChildren(theType); } else { comps = EntityManager.instance.GetComponentsInChildren(theType); } foreach (Component c in comps) { c.SendMessage("OnSceneActivate", activate, SendMessageOptions.DontRequireReceiver); } } }
public override bool Update(MonoBehaviour behaviour, Sequencer.StateInstance state) { AIState aiState = (AIState)state; Entity ai = (Entity)behaviour; PlanetAttach pa = ai.planetAttach; Player player = SceneLevel.instance.player; //Debug.Log("side: "+pa.CheckSide(player.planetAttach)); Vector2 prevDir = aiState.curPlanetDir; aiState.curPlanetDir = pa.GetDirTo(player.planetAttach, horizontalOnly); bool done = true; //cap speed on opposite dir if (Vector2.Dot(prevDir, aiState.curPlanetDir) < 0.0f) { if (useBreakSpeed) { pa.velocity = prevDir * breakSpeed; } if (doneAfterNumChangeDir > 0 && aiState.counter < doneAfterNumChangeDir) { aiState.counter++; } } if (doneAfterNumChangeDir > 0) { done = doneAfterNumChangeDir == aiState.counter && Vector2.Dot(pa.planetDir, aiState.curPlanetDir) > 0.0f; } //pa.velocity = Vector2.zero; pa.accel = aiState.curPlanetDir * accel; return(done); }
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { if (entityPath.Length > 0) { GameObject go = ((SceneController)behaviour).SearchObject(entityPath); if (go != null) { Entity e = go.GetComponent <Entity>(); if (e != null) { if (e.stats != null) { if (amount == -1) { if (e.stats.curHP > 1) { e.stats.ApplyDamage(e.stats.curHP - 1); } } else { e.stats.ApplyDamage(amount); } } e.action = action; } else { Debug.LogWarning("Not an entity: " + entityPath); } } else { Debug.LogWarning("Path not found: " + entityPath); } } }
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { if (entityPath.Length > 0) { GameObject go = ((SceneController)behaviour).SearchObject(entityPath); if (go != null) { Entity e = go.GetComponent <Entity>(); if (e != null) { ((SceneController.StateData)state).entity = e; } else { Debug.LogWarning("Not an entity: " + entityPath); } } else { Debug.LogWarning("Path not found: " + entityPath); } } }
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { Entity ai = (Entity)behaviour; PlanetAttach pa = ai.planetAttach; AIState aiState = (AIState)state; float speed = speedMin < speedMax?Random.Range(speedMin, speedMax) : speedMin; if (speed > 0) { if (followPlayer) { Player player = SceneLevel.instance.player; aiState.curPlanetDir = pa.GetDirTo(player.planetAttach, followPlayerHorizontal); } else if (!useDir) { aiState.curPlanetDir = Util.Vector2DRot(new Vector2(1, 0), angle * Mathf.Deg2Rad); } pa.velocity = aiState.curPlanetDir * speed; ai.action = Entity.Action.move; } else { pa.velocity = Vector2.zero; ai.action = Entity.Action.idle; } if (resetAccel) { pa.accel = Vector2.zero; } }
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance _state) { behaviour.SendMessage("SequenceChangeState", state, SendMessageOptions.RequireReceiver); }
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance _state) { Main.instance.userData.SetCurrentLevelState(state); Main.instance.userData.SetCurrentLevelScore(SceneLevel.instance.player.GetScore()); }
public override void Finish(MonoBehaviour behaviour, Sequencer.StateInstance state) { }
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { Entity ai = (Entity)behaviour; ai.BroadcastMessage("OnAIAnimation", animations, SendMessageOptions.DontRequireReceiver); }
public override bool Update(MonoBehaviour behaviour, Sequencer.StateInstance state) { return(SceneLevel.instance.enemyCount <= amount); }
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { ModalDialog.Open(portrait, name, texts); }
public override bool Update(MonoBehaviour behaviour, Sequencer.StateInstance state) { return(!UIManager.instance.ModalIsInStack(UIManager.Modal.Dialog)); }
//do clean ups here, don't set any states dependent from outside public override void Finish(MonoBehaviour behaviour, Sequencer.StateInstance state) { ((SceneController.StateData)state).entity = null; }