public Field ApplyStep(string[] stepParams, Field field)
        {
            Tuple <int, int, ShootDirection> parsedParams = parseAndVerifyParameters(stepParams, field);

            int            botX      = parsedParams.Item1;
            int            botY      = parsedParams.Item2;
            ShootDirection direction = parsedParams.Item3;

            Tuple <int, int> step = movePointByDirection(botX, botY, direction);

            int shootX = step.Item1, shootY = step.Item2;

            while (shootX >= 0 && shootX < field.Width && shootY >= 0 && shootY < field.Height)
            {
                if (field.Points[shootY][shootX] == Point.BlueBot || field.Points[shootY][shootX] == Point.RedBot)
                {
                    field.Points[shootY][shootX] = Point.Empty;
                    break;
                }

                if (field.Points[shootY][shootX] == Point.Obstacle)
                {
                    break;
                }

                step   = movePointByDirection(shootX, shootY, direction);
                shootX = step.Item1;
                shootY = step.Item2;
            }

            return(field);
        }
Example #2
0
 public Bullet(MinerGame game, Vector2 position, ShootDirection dir)
     : base(game, position)
 {
     this.Width = width;
     this.Height = height;
     this.sprite = game.Content.Load<Texture2D>(ASSET_NAME);
     int one = (dir == ShootDirection.right) ? 1 : -1;
     velocity.X = one * 250.0f;
 }
Example #3
0
    public void changeWeapon(Weapons _newWeapon)
    {
        if (currentWeapon == _newWeapon)
        {
            if (lvlWeapon < lvlWeaponMax)
            {
                lvlWeapon++;
            }
            lvlUpWeapon();
        }
        else
        {
            currentWeapon = _newWeapon;
            nbProjectile  = 0;

            switch (currentWeapon)
            {
            case Weapons.LAZER:
                lvlWeapon       = 1;
                startCDWeapon   = -1;
                cooldownWeapon  = 1;
                nbProjectileMax = 1;
                sizeModificator = 1;
                styleShoot      = ShootDirection.MONO;
                break;

            case Weapons.BULLET:
                lvlWeapon       = 1;
                startCDWeapon   = -1;
                cooldownWeapon  = 0.2f;
                nbProjectileMax = -1;
                sizeModificator = 1;
                styleShoot      = ShootDirection.MONO;
                break;

            case Weapons.MISSILE:
                lvlWeapon       = 1;
                startCDWeapon   = 2;
                cooldownWeapon  = -1;
                nbProjectileMax = 1;
                sizeModificator = 1;
                styleShoot      = ShootDirection.MONO;
                break;

            default:
                currentWeapon   = Weapons.NONE;
                lvlWeapon       = 0;
                startCDWeapon   = -1;
                cooldownWeapon  = -1;
                nbProjectileMax = -1;
                sizeModificator = 0;
                styleShoot      = ShootDirection.MONO;
                break;
            }
        }
    }
    public void Respawn(Transform respawnPos, ShootDirection direction)
    {
        dead = false;
        characterAnimator.SetBool("IsDead", dead);

        transform.position    = new Vector3(respawnPos.position.x, respawnPos.position.y, transform.position.z);
        currentShootDirection = direction;
        charaFlower.SetCurrentGlobalTarget(currentShootDirection == ShootDirection.Left ? leftShootPosition : rightShootPosition, currentShootDirection);
        lifeSystem.ResetLife();
    }
    public void HandleInputs()
    {
        if (dead || won)
        {
            return;
        }

        if ((Input.GetKeyDown(shootingGamepadInput) || Input.GetKeyDown(shootingKeyboardInput)))
        {
            isShootingInputDown = true;
            if (!IsStunned)
            {
                StartShooting();
            }
        }
        else if ((Input.GetKeyUp(shootingGamepadInput) || Input.GetKeyUp(shootingKeyboardInput)))
        {
            isShootingInputDown = false;
        }

        if (IsStunned)
        {
            currentHorizontalInput = 0;
            return;
        }

        currentHorizontalInput = Input.GetAxis(horizontalAxis);
        currentHorizontalInput = (Mathf.Abs(currentHorizontalInput) > minimumAxisValueToConsiderHorizontalMovement) ? Mathf.Sign(currentHorizontalInput) : 0;

        if (currentHorizontalInput != 0)
        {
            ShootDirection previous = currentShootDirection;
            currentShootDirection = currentHorizontalInput > 0 ? ShootDirection.Right : ShootDirection.Left;
            if (previous != currentShootDirection)
            {
                charaFlower.SetCurrentGlobalTarget(currentShootDirection == ShootDirection.Left ? leftShootPosition : rightShootPosition, currentShootDirection);
            }
        }

        if (GetJumpKeyDown)
        {
            if (IsOnGround || CanLateJump)
            {
                StartJumping();
            }
            else
            {
                StartExtentJumpDelay();
            }
        }
        else if (GetJumpKeyUp && isJumping)
        {
            EndJumping();
        }
    }
Example #6
0
    private void Update()
    {
        ShootDirection previous = currentShootDirection;

        currentShootDirection = GetShootDirection;
        if (currentShootDirection != previous)
        {
            rendererParent.rotation = Quaternion.Euler(0, currentShootDirection == ShootDirection.Right ? rightRotation : leftRotation, 0);
        }

        UpdateBehavior();
    }
Example #7
0
    public void lvlUpBullet()
    {
        switch (lvlWeapon)
        {
        case 2:
            styleShoot = ShootDirection.TRIPLE;
            break;

        case 3:
            styleShoot = ShootDirection.OMNI;
            break;
        }
    }
Example #8
0
    public void ShootProjectile()
    {
        ShootDirection shootDirectionEnum = currentShootDirection;
        Vector3        shootPosition      = shootDirectionEnum == ShootDirection.Right ? rightShootPosition.position : leftShootPosition.position;
        Vector3        shootDirection     = shootDirectionEnum == ShootDirection.Right ? Vector3.right : Vector3.left;

        shootDirection = Quaternion.Euler(0, 0, shootAngle * (shootDirectionEnum == ShootDirection.Right ? 1 : -1)) * shootDirection;

        /*print("SHOOT");
         * Debug.DrawRay(shootPosition, shootDirection * 5.0f, Color.magenta, 0.25f);*///
        ProjectileBase newProj = Instantiate(enemyProjectilePrefab, shootPosition, Quaternion.identity);

        newProj.ShootProjectile(shootDirection, gameObject);

        PlayShootFeedback();
    }
Example #9
0
    // Use this for initialization
    void Awake()
    {
        lvlWeaponMax = 3;

        lvlWeapon       = 0;
        startCDWeapon   = -1;
        cooldownWeapon  = -1;
        nbProjectile    = 0;
        nbProjectileMax = -1;
        sizeModificator = 0;
        styleShoot      = ShootDirection.MONO;
        currentWeapon   = Weapons.NONE;

        changeWeapon(Weapons.BULLET);

        player = transform;
    }
Example #10
0
        // Use this for initialization
        void Awake()
        {
            _anime = GetComponent <Animator>();

            CenterProcess = GameObject.Find("CenterProcess").GetComponent <CenterProcess>();
            _gunsprite    = GunShow.GetComponent <SpriteRenderer>();
            _state        = this.gameObject.GetComponent <State>();

            _bag            = this.gameObject.GetComponent <PlayerBag>();
            _shootDirection = GunShow.GetComponent <ShootDirection>();
            _bag.init();

            _state.Maxhealth += UpgradeTree.PlayerArchive.ExtraHpLevel * SystemOption.ExPlayerHpPerL;
            _state.Health    += UpgradeTree.PlayerArchive.ExtraHpLevel * SystemOption.ExPlayerHpPerL;
            _state.Armor     += UpgradeTree.PlayerArchive.ExtraArmorLevel * SystemOption.ExPlayerArmorPerL;

            this.gameObject.transform.localScale = new Vector3(-_playerFlipScale, _playerFlipScale, _playerFlipScale);
        }
        private Tuple <int, int, ShootDirection> parseAndVerifyParameters(string[] input, Field field)
        {
            if (input.Length != 3)
            {
                throw new ArgumentException($"Shoot action requires 3 parameters - bot position (x, y) and shoot direction. But got { input.ToString() }");
            }

            int            botX      = int.Parse(input[0]);
            int            botY      = int.Parse(input[1]);
            ShootDirection direction = (ShootDirection)Enum.Parse(typeof(ShootDirection), input[2]);

            if (field.Points[botY][botX] != Point.BlueBot && field.Points[botY][botX] != Point.RedBot)
            {
                throw new ArgumentException("Point addresed by bot position doesn't containing any bot.");
            }

            return(new Tuple <int, int, ShootDirection>(botX, botY, direction));
        }
        private Tuple <int, int> movePointByDirection(int x, int y, ShootDirection direction)
        {
            switch (direction)
            {
            case ShootDirection.Top:
                y--;
                break;

            case ShootDirection.Bottom:
                y++;
                break;

            case ShootDirection.Left:
                x--;
                break;

            case ShootDirection.Right:
                x++;
                break;
            }

            return(new Tuple <int, int>(x, y));
        }
    public static System.Tuple <int, int, Vector2> SetShootValues(ShootDirection shootDirection)
    {
        int     instantDestroyDistance;
        int     fireLength;
        Vector2 direction = Vector2.zero;

        switch (shootDirection)
        {
        case ShootDirection.Up: direction = Vector2.up;
            break;

        case ShootDirection.Right:
            direction = Vector2.right;
            break;

        case ShootDirection.Left:
            direction = Vector2.left;
            break;

        case ShootDirection.Down:
            direction = Vector2.down;
            break;
        }

        if (shootDirection == ShootDirection.Right || shootDirection == ShootDirection.Left)
        {
            instantDestroyDistance = 1;
            fireLength             = 16;
        }
        else
        {
            instantDestroyDistance = 0;
            fireLength             = 9;
        }

        return(System.Tuple.Create(instantDestroyDistance, fireLength, direction));
    }
Example #14
0
    // Use this for initialization
    void Start()
    {
        // objects to be placed

        object_lever  = GameObject.Find("lever_placed");
        object_ramp   = GameObject.Find("ramp_placed");
        object_wedge  = GameObject.Find("Wedge_placed");
        object_pulley = GameObject.Find("pulley_placed");

        // scripts attached to inventories:
        lever        = GameObject.Find("Lever").GetComponent <UpdateCursor_lever_button> ();
        ramp         = GameObject.Find("Ramp").GetComponent <UpdateCursor_ramp_button> ();
        wedge        = GameObject.Find("Wedge").GetComponent <UpdateCursor_wedge_button> ();
        eraser       = GameObject.Find("Eraser").GetComponent <UpdateCursor_eraser_button> ();
        crossbow     = GameObject.Find("Crossbow").GetComponent <UpdateCursor_crossbow_button> ();
        plank        = GameObject.Find("PlankSprite").GetComponent <WedgePlank> ();
        pulleyplank1 = GameObject.Find("PlankRight").GetComponent <plankz1> ();
        pulleyplank2 = GameObject.Find("PlankLeft").GetComponent <plankz2> ();
        shoot        = GameObject.Find("Gun Location").GetComponent <ShootDirection> ();
        pulley       = GameObject.Find("Pulley").GetComponent <UpdateCursor_pulley_button> ();

        // cursor:
        cursor = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <HandleCursor> ();

        pprightPos = pulleyplank1.transform.position;
        ppleftPos  = pulleyplank2.transform.position;

        // help box:
        panel_rotate = GameObject.Find("help_rotate");
        panel_rotate.SetActive(false);
        // 1: has soft reset; 0: new game
        softreset = PlayerPrefs.GetInt("reset");

        // animator:
        animator = GameObject.Find("Billie").GetComponent <Animator>();
    }
Example #15
0
 /// <summary>
 /// Implementacja interfejsu IRangeAttacker. Metoda wywoływana przez postać atakującą na odległość.
 /// </summary>
 /// <param name="direction">Wyliczenie określające kierunek strzału</param>
 /// <param name="damage">Wartość zadanych obrażeń</param>
 /// <returns>Obiekt pocisku stworzony w wyniku strzału</returns>
 public Bullet RangeAttack(ShootDirection direction, int damage)
 {
     throw new NotImplementedException();
 }
Example #16
0
 public void SetCurrentGlobalTarget(Transform target, ShootDirection direction)
 {
     currentGlobalTargetTr = target;
     currentAttackTr       = direction == ShootDirection.Left ? leftAttackTr : rightAttackTr;
 }
Example #17
0
 /// <summary>
 /// Implementacja interfejsu IRangeAttacker. Metoda wywoływana przez postać atakującą na odległość.
 /// </summary>
 /// <param name="direction">Wyliczenie określające kierunek strzału</param>
 /// <param name="damage">Wartość zadanych obrażeń</param>
 /// <returns>Obiekt pocisku stworzony w wyniku strzału</returns>
 public Bullet RangeAttack(ShootDirection direction, int damage)
 {
     return new Bullet(this.game, new Vector2(this.Position.X, this.Position.Y + 0.5f * (float)Field.FieldHeight), direction);
 }
Example #18
0
 void Awake()
 {
     Instance = this;
 }