// #DEPRECATED
    public Hazard LaunchMissile(GridBlock currentGrid, Vector2Int facingDirection)
    {
        if (weaponAmmunition > 0)
        {
            Vector3     currentWorldLocation = new Vector3(currentGrid.location.x, currentGrid.location.y, 0);
            GameObject  missile  = Instantiate(onGridWeaponPrefab, currentWorldLocation, transform.rotation);
            MovePattern movement = missile.GetComponent <MovePattern>();

            if (facingDirection == Vector2Int.up)
            {
                movement.SetMovePatternUp();
            }
            else if (facingDirection == Vector2Int.down)
            {
                movement.SetMovePatternDown();
            }
            else if (facingDirection == Vector2Int.left)
            {
                movement.SetMovePatternLeft();
            }
            else if (facingDirection == Vector2Int.right)
            {
                movement.SetMovePatternRight();
            }

            weaponAmmunition -= 1;

            launchedMissile = missile.GetComponent <Hazard>();
            return(launchedMissile);
        }
        else
        {
            return(null);
        }
    }
Exemple #2
0
    private void PlayerInput()
    {
        // Weapon Selection
        if (Input.GetKeyDown(KeyCode.Q))
        {
            SelectWeapon(-1);
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            SelectWeapon(1);
        }

        // Player Movement & turn advancement

        if (Input.GetKeyDown(KeyCode.W))
        {
            transform.rotation = Quaternion.AngleAxis(0, Vector3.forward);
            currentlyFacing    = Vector2Int.up;
            movePattern.SetMovePatternUp();
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            transform.rotation = Quaternion.AngleAxis(180.0f, Vector3.forward);
            currentlyFacing    = Vector2Int.down;
            movePattern.SetMovePatternDown();
        }

        if (Input.GetKeyDown(KeyCode.A))
        {
            transform.rotation = Quaternion.AngleAxis(90.0f, Vector3.forward);
            currentlyFacing    = Vector2Int.left;
            movePattern.SetMovePatternLeft();
        }

        if (Input.GetKeyDown(KeyCode.D))
        {
            transform.rotation = Quaternion.AngleAxis(-90.0f, Vector3.forward);
            currentlyFacing    = Vector2Int.right;
            movePattern.SetMovePatternRight();
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            IsAttackingThisTick = true;
            if (OnPlayerAdvance != null)
            {
                OnPlayerAdvance();
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (OnPlayerAdvance != null)
            {
                OnPlayerAdvance();
            }
        }

        if (Input.GetKeyDown(KeyCode.T))
        {
            // Debug button
        }
    }
Exemple #3
0
    // METHODS
    public virtual void Init(string spawnBorder)
    {
        currentMode = GridObject.Mode.Spawn;
        Health hp = GetComponent <Health>();

        if (hp != null)
        {
            hp.ToggleInvincibility(true);
        }

        MovePattern movement = GetComponent <MovePattern>();

        if (movement != null)
        {
            switch (spawnBorder)
            {
            case "Bottom":
                movement.SetMovePatternUp();
                break;

            case "Top":
                if (spawnRules.requiresOrientation)
                {
                    transform.rotation = Quaternion.Euler(0.0f, 0.0f, 180.0f);
                    spawnWarningObject.transform.localRotation = Quaternion.Euler(0.0f, 0.0f, 180.0f);
                }
                movement.SetMovePatternDown();
                break;

            case "Right":
                if (spawnRules.requiresOrientation)
                {
                    transform.rotation = Quaternion.Euler(0.0f, 0.0f, 90.0f);
                    spawnWarningObject.transform.localRotation = Quaternion.Euler(0.0f, 0.0f, 270.0f);
                }
                movement.SetMovePatternLeft();
                break;

            case "Left":
                if (spawnRules.requiresOrientation)
                {
                    transform.rotation = Quaternion.Euler(0.0f, 0.0f, 270.0f);
                    spawnWarningObject.transform.localRotation = Quaternion.Euler(0.0f, 0.0f, 90.0f);
                }
                movement.SetMovePatternRight();
                break;
            }
        }

        Rotator r = GetComponent <Rotator>();

        if (r != null)
        {
            if (!r.enabled)
            {
                r.enabled = true;
            }
            r.ApplyRotation(spawnBorder);
        }

        //ticksRemainingUntilMove = ticksPerMove;
        SetGamePlayMode(Mode.Spawn);
    }