1234567891011121314151617181920212223242526272829303132333435363738 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using KairoEngine.Core;
- namespace KairoEngine.CharacterSystem
- {
- public class MoveCommand : ICommand
- {
- CharacterController character;
- Vector2 direction;
- Vector2 lookDirection;
- float speed;
- public MoveCommand(CharacterController character, Vector2 direction, Vector2 lookDirection, float speed)
- {
- this.character = character;
- this.direction = direction;
- this.lookDirection = lookDirection;
- this.speed = speed;
- }
- public void Execute()
- {
- CharacterMoveAction action = new CharacterMoveAction(character, direction, lookDirection, speed);
- ActionController actionController = character.GetComponent<ActionController>();
- if(actionController.HasAction(action) == false)
- {
- actionController.AddAction(action);
- }
- else
- {
- actionController.ChangeAction(action);
- }
- }
- }
- }
|