コード例 #1
0
    public void SetActive(bool isActive)
    {
        this.isActive = isActive;
        fireEnabled   = isActive;

        if (isActive)
        {
            fuelAmount = 100;
            GameController.GetInstance().fuel.fillAmount = 1;

            selectedWeapon = activeWeapons[0];
            MAX_SPEED      = selectedWeapon.power;
            WeaponButton.Instance.UpdateView(selectedWeapon);
            GameController.Instance.PrepareWeaponList(usedWeaponIds);
        }

        if (!isAI)
        {
            projectileHolder.gameObject.SetActive(isActive);
            canvas.gameObject.SetActive(isActive);
        }
    }
コード例 #2
0
ファイル: WeaponButton.cs プロジェクト: mzijewel/TankOne
 public void UpdateView(RowWeapon weapon)
 {
     imgButton.sprite = weapon.sprIcon;
 }
コード例 #3
0
 public void ChangeWeapon(RowWeapon weapon)
 {
     activePlayer.selectedWeapon = weapon;
 }
コード例 #4
0
    private IEnumerator IStartAI()
    {
        yield return(new WaitForSeconds(2));

        float angle = 0;

        Vector2[] posiblePositions = new Vector2[4];
        Transform enemy            = GameController.Instance.player1.transform;

        float distance = Mathf.Abs(enemy.position.x - transform.position.x);


        float time = Random.Range(2, 6);
        float acc  = distance > 20 ? -1 : 1;

        if (GameData.playerState.isSound)
        {
            audioSource.Play();
        }
        JointMotor2D motor = new JointMotor2D {
            motorSpeed = carSpeed * acc, maxMotorTorque = 10000
        };

        while (time > 0)
        {
            frontWheel.motor = motor;
            backWheel.motor  = motor;
            midleWheel.motor = motor;
            time            -= Time.deltaTime;
            yield return(0);
        }
        acc   = 0;
        motor = new JointMotor2D {
            motorSpeed = carSpeed * acc, maxMotorTorque = 10000
        };
        frontWheel.motor = motor;
        backWheel.motor  = motor;
        midleWheel.motor = motor;

        if (audioSource.isPlaying)
        {
            audioSource.Stop();
        }


        posiblePositions[0] = new Vector2(enemy.position.x - 3, enemy.position.y);
        posiblePositions[1] = new Vector2(enemy.position.x, enemy.position.y);
        posiblePositions[2] = new Vector2(enemy.position.x + 3, enemy.position.y);
        posiblePositions[3] = new Vector2(enemy.position.x + 5, enemy.position.y);
        int pos = Random.Range(0, posiblePositions.Length);

        Vector2 target   = posiblePositions[pos];
        Vector2 velocity = Calculate(target);

        angle = Vector2.Angle(Vector2.right, velocity);

        turret.eulerAngles = Vector3.forward * angle;

        yield return(new WaitForSeconds(0.5f));



        int index = Random.Range(0, activeWeapons.Count);

        selectedWeapon = activeWeapons[index];
        usedWeaponIds.Add(selectedWeapon.id);
        activeWeapons.RemoveAt(index);

        LAUNCH_VELOCITY = velocity;

        Fire();
    }
コード例 #5
0
 public void SetWeapon(RowWeapon weapon)
 {
     selectedWeapon = weapon;
     MAX_SPEED      = selectedWeapon.power;
 }