void Awake() { a_UpVector = GetComponent <IGravity>(); //Get the main camera aimer = GetComponent <IAim>(); //Get the main camera Anim = GetComponent <Animator>(); //Get the main camera aimer.IgnoreTransform = transform; }
void Start() { moveDirection = Vector3.zero; cc = GetComponent <CharacterController>(); movement = new KeyboardController(); aim = new MouseController(); }
public static void Main() { Console.CursorVisible = false; // Setting the console height and width. Console.BufferHeight = Console.WindowHeight = Constants.WorldRows + 1; Console.BufferWidth = Console.WindowWidth = Constants.WorldCols; // Creating a renderer with the console height and width. IRenderer renderer = new ConsoleRenderer(Constants.WorldRows, Constants.WorldCols); // Assigning the user input to the keyboard. IUserKeyboardInput userInput = new KeyboardInput(); // Creating an aim for the console user experience. IAim aim = Aim.Instance; // Ataching the aim methods to the userInput events userInput.OnDownPressed += (sender, args) => { aim.MoveDown(); }; userInput.OnLeftPressed += (sender, args) => { aim.MoveLeft(); }; userInput.OnRightPressed += (sender, args) => { aim.MoveRight(); }; userInput.OnUpPressed += (sender, args) => { aim.MoveUp(); }; GameInitializator gameInitializator = new GameInitializator(); // Creating an engine of the game. Engine engine = new Engine(renderer, userInput, aim, gameInitializator); // Starting the game. engine.Start(); }
void OnTriggerExit(Collider other) { if (other.isTrigger) { return; //Ignore if the Collider exiting is a Trigger } IAim Aimer = other.GetComponentInParent <IAim>(); if (Aimer != null) { Aimer.ForcedTarget = null; OnAimEnter.Invoke(false); } }
public Engine(IRenderer renderer, IUserKeyboardInput userInput, IAim aim, GameInitializator gameInitializator) { this.Renderer = renderer; this.UserInput = userInput; this.Aim = aim; this.GameInitializator = gameInitializator; random = new Random(); this.gameObjects = new HashSet <GameObject>(); this.farm = new Farm(); this.farmManager = new FarmManager(); this.market = new Market(); this.presentFactory = new PresentFactory(); }
public Engine(IRenderer renderer, IUserKeyboardInput userInput, IAim aim, GameInitializator gameInitializator) { this.Renderer = renderer; this.UserInput = userInput; this.Aim = aim; this.GameInitializator = gameInitializator; random = new Random(); this.gameObjects = new HashSet<GameObject>(); this.farm = new Farm(); this.farmManager = new FarmManager(); this.market = new Market(); this.presentFactory = new PresentFactory(); }
void OnTriggerEnter(Collider other) { if (other.isTrigger) { return; //Ignore if the Collider entering is a Trigger } IAim Aimer = other.GetComponentInParent <IAim>(); if (Aimer != null) { //Aimer.Active = true; Aimer.ForcedTarget = transform; OnAimEnter.Invoke(true); } }
public override void StartEffect(Effect effect) { rb = effect.Instance.GetComponent <Rigidbody>(); //Get the riggidbody of the effect aim = effect.Owner.GetComponent <IAim>(); //Check if the owner has lookAt effect.Instance.SendMessage("SetOwner", effect.Owner, SendMessageOptions.DontRequireReceiver); if (aim != null && aim.Active && !aim.Limited) { rb.AddForce(aim.AimDirection.normalized * velocity); //If it has look at take the direction from te lookat } else { Animator ownerAnimator = effect.Owner.GetComponent <Animator>(); Vector3 velocityv = ownerAnimator.velocity.normalized; if (ownerAnimator.velocity.magnitude < 0.1) { velocityv = effect.Owner.transform.forward; } rb.AddForce(velocityv * velocity); } }
public ModificationAim(IAim aim, Vector3 aimPosition) { _aim = aim; _aimPosition = aimPosition; }
private void Awake() { _aim = _aimObject.GetComponent <IAim>(); _gun = _gunObject.GetComponent <IGun>(); _input = GetComponent <IInput>(); }