// Update is called once per frame
        void Update()
        {
            if (KSInput.GetPlatformType() == KSInput.PlatformType.PC)
            {
                if (Input.GetKey(KeyCode.LeftArrow))
                {
                    movementSystem.Move(Vector3.left);
                }
                if (Input.GetKey(KeyCode.RightArrow))
                {
                    movementSystem.Move(Vector3.right);
                }
                if (Input.GetKey(KeyCode.DownArrow))
                {
                    movementSystem.Move(Vector3.down);
                }
                if (Input.GetKey(KeyCode.UpArrow))
                {
                    movementSystem.Move(Vector3.up);
                }
            }

            if (KSInput.HasInput())
            {
                KSInput.SetStartPosition();
                movementSystem.Move(KSInput.GetDeltaPosition());
            }

            attackSystem.Shoot();
        }
예제 #2
0
        // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
        override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            brain = animator.GetComponent <BrainManager>();
            ms    = animator.GetComponent <MovementSystem>();

            brain.outline.enabled = true;
            float min            = Vector3.Distance(animator.transform.position, brain.manager.playerUnits[0].transform.position);
            int   playerToAttack = 0;

            for (int i = 0; i < brain.manager.playerUnits.Count; i++)
            {
                float temp = Vector3.Distance(animator.transform.position, brain.manager.playerUnits[i].transform.position);
                if (temp < min)
                {
                    min            = temp;
                    playerToAttack = i;
                }
            }
            Tile targetedPlayer = brain.manager.playerUnits[playerToAttack].GetComponent <MovementSystem>().currentTile;

            PickTarget(targetedPlayer);

            if (target && target.unitOnTile == null)
            {
                ms.Move(target);
            }
            else
            {
                ms.finishedMoving = true;
                Debug.Log("Does not have target location");
            }
        }
예제 #3
0
    void FixedUpdate()
    {
        var hInput        = (int)Input.GetAxisRaw("Horizontal");
        var vInput        = (int)Input.GetAxisRaw("Vertical");
        var jumpContInput = Input.GetButton("Jump");

        _movementSystem.Move(hInput, vInput, _jumpStartInput, jumpContInput, Time.fixedDeltaTime);
        _jumpStartInput = false;
    }
예제 #4
0
 void Update()
 {
     healthBar.value = (currentHealth / maxHealth);
     if (currentHealth <= 0)
     {
         Die();
     }
     movementSystem.Move();
     combatSystem.ManageAttack();
 }
예제 #5
0
 void Update()
 {
     selectIndicator.SetActive(selected && GameManager.gm.RTSMode);
     healthBar.value = (currentHealth / maxHealth);
     if (currentHealth <= 0)
     {
         Die();
     }
     movementSystem.Move();
     combatSystem.ManageAttack();
     if (selected)
     {
         selected = false;
     }
 }
        // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
        override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            if (possible == null)
            {
                possible = ms.GetPossible(creature.movementLeft);
            }

            if (!ms.notMoving)
            {
                possible = ms.GetPossible(creature.movementLeft);
            }
            else if (possible != null)
            {
                ms.ShowPossible(possible);
            }
            brain.outline.OutlineColor = Color.blue;
            Ray        ray = brain.cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100, brain.tileMapLayerMask))
            {
                Tile endTile = hit.collider.GetComponent <Tile>();
                brain.tileIndictor.transform.position = endTile.GetCenterOfTile();
                if (endTile.unitOnTile == null && Input.GetButtonDown("Fire1") && possible != null)
                {
                    bool a = false;
                    foreach (Tile tile in possible)
                    {
                        if (endTile == tile)
                        {
                            a = true;
                        }
                    }

                    if (a)
                    {
                        if (EventSystem.current.IsPointerOverGameObject())
                        {
                            return;
                        }
                        ms.Move(endTile, true);
                    }
                }
            }
            if (brain.HasActionLeft())
            {
                if (abilitySelector.currentlySelectedNum > 0)
                {
                    if (ms.finishedMoving)
                    {
                        animator.SetInteger("Ability", abilitySelector.currentlySelectedNum - 1);
                        animator.SetBool("UseAbility", true);
                        abilitySelector.ResetAbilitySelection(-1);
                        ms.finishedMoving = false;
                    }
                }
            }

            if (Input.GetButtonDown("Next"))
            {
                brain.isMyTurn = false;
            }
        }
예제 #7
0
        public void Run()
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();
            PositionComponent cameraPosition = LoadMapEntitiesAndReturnPlayer();
            var gameConsole = new ConsoleWindow(ConsoleHeigth, ConsoleWidth, "RogueLike");
            var camera      = new Camera(cameraPosition, 31, visionSystem);

            worldSystem.InitializeLocalMap(new PositionComponent(0, 0));
            stopWatch.Stop();
            Console.WriteLine("setup");
            Console.WriteLine($"ms:{stopWatch.ElapsedMilliseconds} ticks:{stopWatch.ElapsedTicks}");
            stopWatch.Reset();
            while (gameConsole.WindowUpdate())
            {
                if (gameConsole.KeyPressed)
                {
                    PositionComponent newPos        = camera.Position.GetCopy();
                    MovementDirection?moveDirection = null;
                    //Input
                    switch (gameConsole.GetKey())
                    {
                    case Key.Down:
                        moveDirection = MovementDirection.South;
                        break;

                    case Key.Up:
                        moveDirection = MovementDirection.North;

                        break;

                    case Key.Left:
                        moveDirection = MovementDirection.West;

                        break;

                    case Key.Right:
                        moveDirection = MovementDirection.East;
                        break;
                    }



                    stopWatch.Start();
                    if (moveDirection.HasValue)
                    {
                        if (movementSystem.CanBeMovedTo(camera.Position, moveDirection.Value))
                        {
                            movementSystem.Move(camera.Position, moveDirection.Value, 100);
                        }
                    }


                    stopWatch.Stop();
                    Console.Write("CanMove:");
                    Console.WriteLine($"ms:{stopWatch.ElapsedMilliseconds} ticks:{stopWatch.ElapsedTicks}");
                    stopWatch.Reset();

                    stopWatch.Start();


                    worldSystem.CheckAndMoveChunks(camera.Position);
                    visionSystem.ClearMask();
                    visionSystem.SetVisiblePositions(camera.Position, 13);

                    timeTrackingSystem.AdvanceTime(100);

                    var view = camera.GetCurrentViewWithLight(worldSystem);
                    drawingSystem.Render(gameConsole, view);

                    stopWatch.Stop();
                    Console.Write("ViewMask:");
                    Console.WriteLine($" ms:{stopWatch.ElapsedMilliseconds} ticks:{stopWatch.ElapsedTicks}");
                    stopWatch.Reset();
                    gameConsole.Write(0, 40, $"CameraPos Y:{camera.Position.YCoord},X:{camera.Position.XCoord}", Color4.White);
                    gameConsole.Write(1, 40, $"TopLeftChunk Y:{worldSystem.TopLeftCorner.YCoord},X:{worldSystem.TopLeftCorner.XCoord}".PadRight(30), Color4.White);
                    gameConsole.Write(2, 40, $"Current Chunk Y:{worldSystem.PositionInChunk(cameraPosition).ToString()}".PadRight(30), Color4.White);
                    gameConsole.Write(3, 40, $"Current World Time: {timeTrackingSystem.CurrentTime}.".PadRight(30), Color4.White);
                }
            }
        }
예제 #8
0
파일: Unit.cs 프로젝트: SNYW/ChokePoint
 void Update()
 {
     movementSystem.Move();
     combatSystem.ManageAttack();
 }