private void Start() { SetStateMachine(); target = FindObjectOfType <Player>().transform; moveBehaviour = GetComponent <IMoveBehaviour>(); animator = GetComponent <Animator>(); }
private void Start() { SetStateMachine(); target = FindObjectOfType <Player>().transform; nodes = new List <ANode>(FindObjectOfType <NodesList>().GetNodes()); moveBehaviour = GetComponent <IMoveBehaviour>(); animator = GetComponent <Animator>(); }
public IMoveBehaviour[] AllEmpty(IMoveBehaviour[] original) { IMoveBehaviour[] clone = new IMoveBehaviour[original.Length]; for (int i = 0; i < original.Length; i++) { clone[i] = original[i]; original[i] = new Empty(); } return(clone); }
private void Awake() { moveBehaviour = GetComponent <MoveBehaviour>(); if (moveBehaviour == null) { moveBehaviour = gameObject.AddComponent <MoveBehaviour>(); } moveBehaviour.Init(playerMovementData); EventManager.AddListener(Events.HORIZONTAL_INPUT, OnHorizontalInput); EventManager.AddListener(Events.VERTICAL_INPUT, OnVerticalInput); EventManager.AddListener(Events.JUMP_INPUT, OnJumpInput); EventManager.AddListener(Events.PLAYER_IN_AIR, OnPlayerInAir); }
private void UpdateInput() { KeyboardState state = Keyboard.GetState(); int type; if (state.IsKeyDown(Keys.S) & !previousState.IsKeyDown(Keys.S)) #region Observer Pattern { NotifyObservers(); } #endregion if (state.IsKeyDown(Keys.B) & !previousState.IsKeyDown(Keys.B)) { type = new Random().Next(1, 7 + 1); switch (type) { case 1: moveBehaviour = new CircleWalk(position, 80); break; case 2: moveBehaviour = new CosineWalk(position, 200); break; case 3: moveBehaviour = new SineWalk(position, 200); break; case 4: moveBehaviour = new XWalk(); break; case 5: moveBehaviour = new YWalk(); break; case 6: moveBehaviour = new XYWalk(); break; case 7: moveBehaviour = new NoWalk(); break; } } previousState = state; }
public TownCenter(GraphicsDeviceManager g, Vector2 pos, Vector2 dir) { graphics = g; position = pos; direction = dir; pixel = new Texture2D(graphics.GraphicsDevice, 1, 1); pixel.SetData(new Color[] { Color.Red }); moveBehaviour = new CircleWalk(position, 280); #region Observer Pattern observers = new List <IObserver>(); #endregion previousState = Keyboard.GetState(); }
// Use this for initialization void Start() { if (currentNode == null) { Debug.LogError(name + " no refernce to NodePath found"); } deathBehaviour = GetComponent <IDeathBehaviour>(); if (deathBehaviour == null) { Debug.LogError(name + " no IDeathBehaviour attached to gameobject"); } moveBehaviour = GetComponent <IMoveBehaviour>(); if (deathBehaviour == null) { Debug.LogError(name + " no IMoveBehaviour attached to gameobject"); return; } }
public void SignalChange() { if (flip) { old_behaviour = moveBehaviour; moveBehaviour = new ToTownCenterWalk(towncenter); old_position = position; old_direction = direction; flip = false; } else { // Herpositioneren op de kaart position = old_position; direction = old_direction; moveBehaviour = old_behaviour; flip = true; } }
private static IEnumerator MoveCoroutine( Transform target, IMoveBehaviour move, float executionTime, Action onFinish ) { var timeElapsed = 0f; while (timeElapsed <= executionTime && executionTime > 0f) { var executionProgress = timeElapsed / executionTime; target.position = move.GetProgressPosition(executionProgress); yield return(null); timeElapsed += Time.deltaTime; } target.position = move.GetProgressPosition(1f); onFinish(); }
internal static void Spawn(ILane lane) { Zombie zombie; if (_spawnableZombies.Count > 0) { zombie = _spawnableZombies.Pop() as Zombie; zombie.gameObject.SetActive(true); } else { zombie = Instantiate(_zombiePrefabRef, lane.ZombieParent); } zombie.transform.localRotation = Quaternion.Euler(0, -90, 0); zombie.transform.position = lane.ZombieParent.position + zombie.transform.forward * UnityEngine.Random.Range(-1f, 1f) + zombie.transform.right * UnityEngine.Random.Range(-1f, 1f); _moveBehaviour = new ZombieMoveBehaviour(zombie); _meleeBehaviour = new ZombieMeleeBehaviour(zombie); zombie.Init(lane.ZombieHP, _zombieSpeedRef, lane.RewardPerZombie, _moveBehaviour, _meleeBehaviour); lane.AddZombie(zombie); }
public void ExecuteMove(Transform target, IMoveBehaviour move, float executionTime, Action onFinish) { moveCoroutine = StartCoroutine(MoveCoroutine(target, move, executionTime, onFinish)); }
void SetMoveBehaviour(IMoveBehaviour moveType) { moveBehaviour = moveType; }
private void ExecuteMove(IMoveBehaviour move) { moveExecutor.ExecuteMove(model.Target, move, model.ExecutionTime, OnFinishMove); }
public void SetMoveBehaviour(IMoveBehaviour moveBehaviour) { this.moveBehaviour = moveBehaviour; }
public Mage() { castSpellBehaviour = new FireBallSpellBehaviour(); moveBehaviour = new MoveBehaviour(); }