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 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 override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state) { Entity ai = (Entity)behaviour; PlanetAttach pa = ai.planetAttach; pa.maxVelocity = velocity; }
void OnPlanetLand(PlanetAttach pa) { if (!mFirstLand) { mFirstLand = true; SetTentacleVulnerable(true); } }
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); }
void OnPlanetLand(PlanetAttach pa) { //perform proper animation if(creature != null) { if(creature.action != Entity.Action.NumActions) PlayAnim(creature.action); } }
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; }
void OnPlanetLand(PlanetAttach pa) { //perform proper animation if (creature != null) { if (creature.action != Entity.Action.NumActions) { PlayAnim(creature.action); } } }
void OnPlanetLand(PlanetAttach pa) { //perform proper animation switch(player.action) { case Entity.Action.hurt: break; default: PlayAnim(player.action); break; } }
protected virtual void Awake() { mStats = GetComponent <EntityStats>(); mPlanetAttach = GetComponent <PlanetAttach>(); Component[] cs = GetComponentsInChildren(typeof(IListener), true); mListeners = new IListener[cs.Length]; for (int i = 0; i < cs.Length; i++) { mListeners[i] = cs[i] as IListener; } }
void OnPlanetLand(PlanetAttach pa) { Vector2 vel = planetAttach.velocity; vel.y = Mathf.Abs(vel.y); planetAttach.velocity = vel; planetAttach.ResetCurYVel(); if (mCurBounce < numBounce) { mCurBounce++; } }
void OnPlanetLand(PlanetAttach pa) { //perform proper animation switch (player.action) { case Entity.Action.hurt: break; default: PlayAnim(player.action); break; } }
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) { 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) { 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; } }
void Update() { switch (mCurState) { case State.Inactive: break; case State.Spawn: Transform t = EntityManager.instance.Spawn(type, null, null, null, useSpawnFX); //set position Vector3 spawnPos = t.position; Vector3 pos = transform.position; Vector2 posSpread = Random.insideUnitCircle * radiusSpread; pos.x += posSpread.x; pos.y += posSpread.y; pos.z = spawnPos.z; t.position = pos; float angle = angleMin != angleMax?Random.Range(angleMin, angleMax) * Mathf.Deg2Rad : angleMin; float speed = speedMin != speedMax?Random.Range(speedMin, speedMax) : speedMin; ProjBullet proj = t.GetComponentInChildren <ProjBullet>(); if (proj != null) { if (useUpVector) { Vector2 u = transform.up; proj.dir = u; } else { proj.dir = Vector2.up; } if (angle != 0) { proj.dir = Util.Vector2DRot(proj.dir, angle); } proj.speed = speed; } else { PlanetAttach pa = t.GetComponentInChildren <PlanetAttach>(); if (pa != null) { Vector2 dir; if (useUpVector) { Vector2 u = transform.up; dir = pa.ConvertToPlanetDir(angle != 0 ? Util.Vector2DRot(u, angle) : u); } else { dir = angle != 0 ? Util.Vector2DRot(Vector2.up, angle) : Vector2.up; } if (horizontalOnly) { dir.x = Mathf.Sign(dir.x); dir.y = 0; } pa.velocity = dir * speed; pa.RefreshPos(); pa.ResetCurYVel(); } } ChangeState(State.SpawnWait); break; case State.SpawnWait: mCurTime += Time.deltaTime; if (mCurTime >= delayPerPeriod) { ChangeState(State.Spawn); } break; case State.PeriodWait: mCurTime += Time.deltaTime; if (mCurTime >= delayPeriod) { ChangeState(State.Spawn); } break; } }
void OnPlanetLand(PlanetAttach pa) { Vector2 vel = planetAttach.velocity; vel.y = Mathf.Abs(vel.y); planetAttach.velocity = vel; planetAttach.ResetCurYVel(); if(mCurBounce < numBounce) { mCurBounce++; } }
void Update() { PlanetAttach planetAttach = mPlayer.planetAttach; float xS = Input.GetAxis("Horizontal"); if (xS > 0.0f) { xS = -1.0f; } else if (xS < 0.0f) { xS = 1.0f; } if (planetAttach.jumpCounter < maxJump) { if (Input.GetButtonDown("Jump")) { mPlayer.action = Entity.Action.jump; planetAttach.Jump(mPlayer.jumpSpeed); if (xS != 0.0f) { planetAttach.velocity.x = xS * mPlayer.moveSpeed; } } } if (planetAttach.jumpCounter == 0 && planetAttach.isGround) { if (xS == 0) { if (mPlayer.action == Entity.Action.move || mPlayer.action == Entity.Action.jump) { mPlayer.action = Entity.Action.idle; planetAttach.velocity.x = 0; } } else { mPlayer.action = Entity.Action.move; planetAttach.velocity.x = xS * mPlayer.moveSpeed; } planetAttach.accel = Vector2.zero; } else if (mPlayer.action == Entity.Action.jump) { planetAttach.accel.x = xS * airControlAccel; } if (Input.GetButtonDown("Fire")) { mGrabber.Fire(true); } else if (Input.GetButtonUp("Fire")) { mGrabber.Fire(false); } else if (Input.GetButtonDown("Expel")) { mGrabber.Expel(); } }
void OnPlanetLand(PlanetAttach pa) { if(!mFirstLand) { mFirstLand = true; SetTentacleVulnerable(true); } }
protected virtual void Awake() { mStats = GetComponent<EntityStats>(); mPlanetAttach = GetComponent<PlanetAttach>(); Component[] cs = GetComponentsInChildren(typeof(IListener), true); mListeners = new IListener[cs.Length]; for(int i = 0; i < cs.Length; i++) { mListeners[i] = cs[i] as IListener; } }