public static void PressDown(ClassKey classKey, string key) { BehaviourAnimation.Play(classKey.gameObject, key); switch (key) { case "Right": MoveShield(classKey, new Vector2(60, 0)); break; case "Left": MoveShield(classKey, new Vector2(-60, 0)); break; case "Up": MoveShield(classKey, new Vector2(0, 60)); break; case "Down": MoveShield(classKey, new Vector2(0, -60)); break; case "Idle": MoveShield(classKey, new Vector2(1000, 1000)); break; } }
public bool LateUpdate(StatusObject _status) { if (_status == null || ActiveBehaviourMode == null || ActiveBehaviourModeRule == null) { return(false); } m_ActiveBehaviourMode.Update(); if (m_BehaviourModeRuleTimer >= m_BehaviourModeRuleLength) { if (m_ActiveBehaviourMode.Rule != null && m_ActiveBehaviourMode.Rule.HasModeLink) { SetBehaviourModeByKey(ActiveBehaviourMode.Rule.Link.BehaviourModeKey); } else if (ActiveBehaviourMode.ValidRules.Count > 1) { NextBehaviorModeRule(); } } BehaviourAnimation.Update(ActiveBehaviourModeRule.Animation); ActiveBehaviourModeRule.Inventory.Update(_status.Inventory); return(true); }
public static void Walk(ClassHero classHero, Vector2 directions) { BehaviourPhysics.Move(classHero.gameObject, directions, classHero.speed); BehaviourAnimation.Flip(classHero.gameObject, directions); BehaviourAnimation.Play(classHero.gameObject, "Walk"); }
private void Blink() { BehaviourAnimation.Play(gameObject, "Blink"); float n = Random.Range(5f, 15f); Invoke("Blink", n); }
public void Init(GameObject gameObject) { m_Owner = gameObject; BehaviourAnimation.Init(m_Owner); for (int i = 0; i < BehaviourModes.Count; i++) { m_BehaviourModesKeys.Add(BehaviourModes[i].Key, i); } }
void OnCollisionEnter2D(Collision2D c) { if (c.gameObject.CompareTag("Iten")) { trashCan.controllerTrashCan.Hurt(); controllerEarth.Hurt(); BehaviourAnimation.Float(gameObject, "Life", trashCan.life); } }
public static void Hurt(ClassEarth classEarth) { GameObject camera = GameObject.Find("Game Camera/Effect"); BehaviourAnimation.Play(classEarth.gameObject, "Hurt"); BehaviourAnimation.Play(camera, "Hurt"); BehaviourSound.Play("SFX/Explosion"); Camera.main.GetComponent <Shaker>().Shake(40f, 1); }
public override void Init(ICEWorldBehaviour _component) { base.Init(_component); BehaviourAnimation.Init(_component); for (int i = 0; i < BehaviourModes.Count; i++) { m_BehaviourModesKeys.Add(BehaviourModes[i].Key, i); } }
public void Turn() { if (gameObject.transform.eulerAngles.z == 0) { BehaviourAnimation.Play(gameObject, "TurnDown"); } else { BehaviourAnimation.Play(gameObject, "TurnUp"); } }
public void CollisionBlock(string block) { int lie; switch (block) { case "Block_Up": if (directionArrows == "Up") { directionArrows = "Down"; arrows.BroadcastMessage("Turn"); MoveArrows(-1); lie = Random.Range(0, 2); if (lie == 0) { BehaviourAnimation.Play(blockUp, "Truth"); BehaviourAnimation.Play(blockDown, "Truth"); MoveBlocks(-1); } else { BehaviourAnimation.Play(blockUp, "Lie"); BehaviourAnimation.Play(blockDown, "Lie"); MoveBlocks(1); } } break; case "Block_Down": if (directionArrows == "Down") { directionArrows = "Up"; arrows.BroadcastMessage("Turn"); MoveArrows(1); lie = Random.Range(0, 2); if (lie == 0) { BehaviourAnimation.Play(blockUp, "Truth"); BehaviourAnimation.Play(blockDown, "Truth"); MoveBlocks(1); } else { BehaviourAnimation.Play(blockUp, "Lie"); BehaviourAnimation.Play(blockDown, "Lie"); MoveBlocks(-1); } } break; } }
public static void Attack(ClassHero classHero) { //BehaviourPhysics.Force(classHero.gameObject, Vector2.right * classHero.faceRight, classHero.forceAttack); BehaviourPhysics.Move(classHero.gameObject, Vector2.right * classHero.faceRight, classHero.forceAttack); BehaviourAnimation.Play(classHero.gameObject, "Attack"); if (!classHero.isAttack) { AudioClip audio = classHero.sfx[2]; BehaviourSound.Play(classHero.gameObject, audio); } }
public static void Damage(ClassHero classHero) { classHero.life -= 10; classHero.hp.fillAmount = classHero.life / 100; if (classHero.life <= 0) { GameObject.Find("GameManager").GetComponent <GameScript>().GameOver(); } GameObject.Find("GameManager").GetComponent <ManagerCamera>().DamageEffect(); BehaviourAnimation.Play(classHero.gameObject, "Damage"); AudioClip audio = classHero.sfx[1]; BehaviourSound.Play(classHero.gameObject, audio); }
public void NextBehaviorModeRule(bool _update = false) { if (!ActiveBehaviourIsValid) { PrintDebugLog(this, "NextBehaviorModeRule : invalid Behaviour '" + ActiveBehaviourModeKey + "', please check this mode and its rules!"); } else { // NextRule will be false if there are no rules but also no new rule, the first // case should never be true so we can use _forced to run a simulated rule change // to refresh the parameter and/or start animation and audio files, effects and events // etc. if (m_ActiveBehaviourMode.NextRule() || _update) { if (m_ActiveBehaviourMode.LastRule != null) { BehaviourAnimation.Stop(m_ActiveBehaviourMode.Rule.Animation); m_ActiveBehaviourMode.LastRule.Stop(); } if (m_ActiveBehaviourMode.Rule != null) { if (DebugLogIsEnabled) { PrintDebugLog(this, "NextBehaviorModeRule : Start rule #" + m_ActiveBehaviourMode.Rule.Index + " of Behaviour Mode " + ActiveBehaviourModeKey + "!"); } m_ActiveBehaviourMode.Rule.Start(OwnerComponent); BehaviourAnimation.Play(m_ActiveBehaviourMode.Rule.Animation); BehaviourAudioPlayer.Play(m_ActiveBehaviourMode.Rule.Audio); BehaviourLook.Adapt(m_ActiveBehaviourMode.Rule.Look); //BehaviourMessage.Send( m_ActiveBehaviourMode.Rule.Message ); } m_BehaviourModeRuleLength = m_ActiveBehaviourMode.RuleLength(); m_BehaviourModeRuleTimer = 0; m_BehaviourModeRuleChanged = m_ActiveBehaviourMode.RuleChanged; if (OnBehaviourModeRuleChanged != null && m_BehaviourModeRuleChanged == true) { OnBehaviourModeRuleChanged(Owner, m_ActiveBehaviourMode.Rule, m_ActiveBehaviourMode.LastRule); } } } }
public void NextBehaviorModeRule(bool _forced = false) { if (m_ActiveBehaviourMode == null) { if (m_BehaviourModeValid) { Debug.LogWarning("CAUTION : INVALID BEHAVIOURMODE '" + BehaviourModeKey + "' AT CREATURE '" + m_Owner.gameObject.name.ToUpper() + "'!"); } m_BehaviourModeValid = false; return; } else { m_BehaviourModeValid = true; } if (m_ActiveBehaviourMode.NextRule() || _forced) { BehaviourAnimation.Play(m_ActiveBehaviourMode.Rule); BehaviourAudio.Play(m_ActiveBehaviourMode.Rule.Audio); if (m_ActiveBehaviourMode.LastRule != null) { m_ActiveBehaviourMode.LastRule.StopEffect(); } if (m_ActiveBehaviourMode.Rule != null) { m_ActiveBehaviourMode.Rule.StartEffect(m_Owner); } m_BehaviourModeRuleLength = m_ActiveBehaviourMode.RuleLength(); m_BehaviourModeRuleTimer = 0; m_BehaviourModeRuleChanged = m_ActiveBehaviourMode.RuleChanged; } }
//-------------------------------------------------- // Update //-------------------------------------------------- public void UpdateBegin() { m_BehaviourModeChanged = false; m_BehaviourModeRulesChanged = false; m_BehaviourModeRuleChanged = false; m_BehaviourTimer += Time.deltaTime; m_BehaviourModeRuleTimer += Time.deltaTime; if (m_BehaviourModeRuleLength > 0 && m_BehaviourModeRuleTimer >= m_BehaviourModeRuleLength) { if (ActiveBehaviourModeRuleHasModeLink) { SetBehaviourModeByKey(m_ActiveBehaviourMode.Rule.Links.BehaviourModeKey); } else { NextBehaviorModeRule(); } } BehaviourAnimation.Update(); }
public static void Idle(ClassHero classHero) { BehaviourPhysics.Move(classHero.gameObject, Vector2.right, 0); BehaviourAnimation.Play(classHero.gameObject, "Idle"); }
/// <summary> /// Sets the behaviour mode by key. /// </summary> ///<description>Use this function to change the behaviour of your creature.</description> /// <param name="key">Key.</param> public bool SetBehaviourModeByKey(string _key) { bool _behaviour_mode_changed = false; if (string.IsNullOrEmpty(_key)) { if (m_BehaviourModeKeyIsValid) { PrintDebugLog(this, "SetBehaviourModeByKey : Invalid behaviour mode key, please check the behaviour modes!"); } m_BehaviourModeKeyIsValid = false; } else { m_BehaviourModeKeyIsValid = true; if (ActiveBehaviourModeKey != _key || !ActiveBehaviourIsReady) { if (SetDesignatedBehaviourModeByKey(_key) == null) { PrintDebugLog(this, "SetBehaviourModeByKey : Behaviour Mode '" + m_DesignatedBehaviourModeKey + "' not exists, please check this behaviour mode!"); } else if (m_DesignatedBehaviourMode == null || m_DesignatedBehaviourMode.ValidRules.Count == 0) { PrintDebugLog(this, "SetBehaviourModeByKey : Behaviour Mode '" + m_DesignatedBehaviourModeKey + "' have no valid rules, please check its behaviour modes rules!"); } else { // stops the current behaviour mode include its active rules if (m_ActiveBehaviourMode != null) { BehaviourAnimation.Stop(m_ActiveBehaviourMode.Rule.Animation); m_ActiveBehaviourMode.Stop(); } //BehaviourAudioPlayer.Stop(); m_LastBehaviourMode = m_ActiveBehaviourMode; m_ActiveBehaviourMode = m_DesignatedBehaviourMode; // initialize the active behaviour mode m_ActiveBehaviourMode.Start(OwnerComponent); // initialize the active behaviour mode rule NextBehaviorModeRule(true); m_BehaviourTimer = 0; m_BehaviourModeRulesChanged = true; m_BehaviourModeChanged = true; _behaviour_mode_changed = true; if (OnBehaviourModeChanged != null) { OnBehaviourModeChanged(Owner, m_ActiveBehaviourMode, m_LastBehaviourMode); } } } } return(_behaviour_mode_changed); }
public static void ChangeColor(ClassTrashCan dataTrashCan, string color) { BehaviourAnimation.Play(dataTrashCan.gameObject, "Color_" + color); }
public void Point() { FacadeTrashCan.Score(classTrashCan); BehaviourAnimation.Float(earth, "Life", classTrashCan.life); }
private void EndLoadScreen() { BehaviourAnimation.Play(curtain, "Open"); }
public void StartLoadScreen(string scene) { BehaviourAnimation.Play(curtain, "Close"); StartCoroutine(LoadScene(scene)); }