Exemple #1
0
 void ActivateTempAmmo(AmmoDisplay ammoDisplay, Vector2 position)
 {
     TempAmmo.SetActive(true);
     TempAmmo.transform.position = position;
     TempAmmoImage.sprite        = ammoDisplay.AmmoImage.CurrentSprite;
     _tempAmmoActive             = true;
 }
    private void FindObjects()
    {
        if (FindObjectOfType <AudioManager>() != null)
        {
            _audioManager = FindObjectOfType <AudioManager>();
        }
        else
        {
            Debug.LogWarning("Audio Manager not found in scene");
        }

        if (FindObjectOfType <AmmoDisplay>() != null)
        {
            _ammoDisplay = FindObjectOfType <AmmoDisplay>();
        }
        else
        {
            Debug.LogWarning("Ammo Display not found in scene");
        }

        if (FindObjectOfType <ThrustersDisplay>() != null)
        {
            _thrustersDisplay = FindObjectOfType <ThrustersDisplay>();
        }
        else
        {
            Debug.LogWarning("Thrusters Display not found in scene");
        }
    }
Exemple #3
0
    public void SwitchAmmo(AmmoDisplay ammoDisplay)
    {
        if (_movingAmmo)
        {
            //Debug.Log("switch ammoDisplay = " + ammoDisplay.Type + " with movingAmmoDisplay = " + _movingAmmoDisplay.Type);
            //_lastAmmoDisplayEntered.ShowImage();
            DeactivateMovingAmmo();
            AmmoType ammoType = ammoDisplay.Type;
            ammoDisplay.Initialize(_movingAmmoDisplay.Type);
            _movingAmmoDisplay.Initialize(ammoType);
            _movingAmmo        = false;
            _movingAmmoDisplay = null;

            for (int i = 0; i < AmmoDisplayArray.Length; i++)
            {
                if (AmmoDisplayArray[i].Set)
                {
                    Avatar.Instance.Ammo.AmmoList[i] = AmmoDisplayArray[i].Type;
                }
            }

            LoadingAlert.Present();
            StartCoroutine(SendAmmoArrangeToServer());
        }
    }
Exemple #4
0
 bool CheckWithinBounds(Vector2 position, AmmoDisplay ammoDisplay)
 {
     if (position.x >= ammoDisplay.transform.position.x - BOX_SIZE && position.x <= ammoDisplay.transform.position.x + BOX_SIZE &&
         position.y >= ammoDisplay.transform.position.y - BOX_SIZE && position.y <= ammoDisplay.transform.position.y + BOX_SIZE)
     {
         return(true);
     }
     return(false);
 }
Exemple #5
0
 public void RevertAmmo()
 {
     if (_movingAmmo)
     {
         DeactivateMovingAmmo();
         _movingAmmoDisplay.ShowImage();
         _movingAmmo        = false;
         _movingAmmoDisplay = null;
     }
 }
Exemple #6
0
    public void ActivateMovingAmmo(AmmoDisplay ammoDisplay)
    {
        MovingAmmoImage.sprite = ammoDisplay.AmmoImage.CurrentSprite;
        MovingAmmo.SetActive(true);
        _movingAmmo        = true;
        _movingAmmoDisplay = ammoDisplay;

        _ammoTypeArray = new AmmoType[10];
        for (int i = 0; i < AmmoDisplayArray.Length; i++)
        {
            _ammoTypeArray[i] = AmmoDisplayArray[i].Type;
        }
    }
Exemple #7
0
    private void Start()
    {
        try
        {
            healthDisplayObj = FindObjectOfType <HealthDisplay>();
        }
        catch (NullReferenceException e)
        { }

        try
        {
            ammoDisplayObj = FindObjectOfType <AmmoDisplay>();
        }
        catch (NullReferenceException e)
        { }
    }
 public override void StartWeapon(bool EnemyWeapon_in = false, EnemyTemplateMaster ETM_in = null, HumanoidWeaponExpertise humanoidWeaponExpertise = HumanoidWeaponExpertise.Adept)
 {
     base.StartWeapon(EnemyWeapon_in, ETM_in, humanoidWeaponExpertise);
     EnemyWeapon = EnemyWeapon_in;
     Started     = true;
     if (EnemyWeapon_in)
     {
         projectileParent = GameObject.Find("EnemyProjectiles").transform;
     }
     else
     {
         ammoDisplay      = GameObject.Find("AmmoDisplay").GetComponent <AmmoDisplay>();
         currentAmmoCount = ammoCapacity;
         projectileParent = GameObject.Find("PlayerProjectiles").transform;
     }
 }
Exemple #9
0
 public void RpcSetupGun(int setAmmo, int setReserve)
 {
     if (!hasAuthority)
     {
         return;
     }
     playMove     = gameObject.GetComponentInParent <SurfCharacter>(true);
     ammoDisplay  = playMove.transform.GetComponent <AmmoDisplay>();
     roundManager = GameObject.Find("Canvas_PublicUI(Clone)").transform.GetComponent <UITimeManager>();
     mainCamera   = playMove.transform.GetComponentInChildren <CinemachineVirtualCamera>();
     ammo         = setAmmo;
     reserve      = setReserve;
     scopeOverlay = playMove.gameObject.FindComponentInChildWithTag <Image>("Scope").gameObject;
     mouseLook    = playMove.transform.GetComponent <PlayerCameraController>();
     crosshair    = playMove.gameObject.FindComponentInChildWithTag <Image>("Crosshair").gameObject;
     animator     = transform.GetComponent <Animator>();
     isSetup      = true;
 }
Exemple #10
0
    void Update()
    {
        //Debug.Log(_movingAmmo + " " + Input.GetMouseButtonUp(0));
        if (_movingAmmo)
        {
            AmmoDisplay ammoOverlap = null;
            for (int i = 0; i < AmmoDisplayArray.Length; i++)
            {
                if (CheckWithinBounds(Input.mousePosition, AmmoDisplayArray[i]))
                {
                    ammoOverlap = AmmoDisplayArray[i];
                }
                else
                {
                    if (AmmoDisplayArray[i] != _movingAmmoDisplay)
                    {
                        AmmoDisplayArray[i].ShowImage();
                    }
                }
            }

            if (!Input.GetMouseButton(0))
            {
                if (ammoOverlap != null && ammoOverlap.Set)
                {
                    //Debug.Log("switch " + ammoOverlap.name + " with " + _movingAmmoDisplay.name);
                    SwitchAmmo(ammoOverlap);
                    if (_tempAmmoActive)
                    {
                        DeactivateTempAmmo();
                    }
                }
                else
                {
                    //Debug.Log("revert");
                    RevertAmmo();
                    if (_tempAmmoActive)
                    {
                        DeactivateTempAmmo();
                    }
                }
            }
            else
            {
                if (ammoOverlap != null && ammoOverlap.Set)
                {
                    MovingAmmo.transform.position = ammoOverlap.transform.position;
                    ammoOverlap.HideImage();
                    //Debug.Log("activating temp ammo with " + _movingAmmoDisplay.name);
                    if (_movingAmmoDisplay != ammoOverlap)
                    {
                        ActivateTempAmmo(ammoOverlap, _movingAmmoDisplay.transform.position);
                    }
                }
                else
                {
                    MovingAmmo.transform.position = Input.mousePosition;
                    if (_tempAmmoActive)
                    {
                        DeactivateTempAmmo();
                    }
                }
            }
        }
    }
Exemple #11
0
    // Update is called once per frame
    void Update()
    {
        if (health > maxHealth)
        {
            health = maxHealth;
        }
        if (ammo > maxAmmo)
        {
            ammo = maxAmmo;
        }

        if (ammo > 0)
        {
            haveAmmo = true;
            if (noAmmoInd)
            {
                noAmmoInd.SetActive(false);
            }
        }
        else
        {
            haveAmmo = false;
            if (noAmmoInd)
            {
                noAmmoInd.SetActive(true);
            }
        }

        if (health <= 0)
        {
            GameManager.ChangeLevel(deathSceneIndex);
            health = maxHealth;
        }

        if (healthDisplayObj)
        {
            healthDisplayObj.WriteHealth((int)health);
        }
        else
        {
            try
            {
                healthDisplayObj = FindObjectOfType <HealthDisplay>();
            }
            catch (NullReferenceException e)
            { }
        }

        if (ammoDisplayObj)
        {
            ammoDisplayObj.WriteAmmo(ammo);
        }
        else
        {
            try
            {
                ammoDisplayObj = FindObjectOfType <AmmoDisplay>();
            }
            catch (NullReferenceException e)
            { }
        }
    }
Exemple #12
0
 public override void UnloadContent()
 {
     base.UnloadContent();
     SceneGraphManager.Root.Nodes.Clear();
     ParticleManager.UnloadContent();
     foreach (Instrument inst in _instruments.Values)
     {
         inst.UnloadContent();
     }
     _instruments.Clear();
     _ammoDisplay = null;
 }
Exemple #13
0
        public override void LoadContent()
        {
            base.LoadContent();

            LoadTextures();

            // Sounds
            SoundFxLibrary.AddToLibrary("SoundFX/bomb1", "bomb1");
            SoundFxLibrary.AddToLibrary("SoundFX/bomb2", "bomb2");
            SoundFxLibrary.AddToLibrary("SoundFX/bomb3", "bomb3");
            SoundFxLibrary.AddToLibrary("SoundFX/bomb4", "bomb4");
            SoundFxLibrary.AddToLibrary("SoundFX/huge_explosion", "huge_explosion");
            SoundFxLibrary.AddToLibrary("SoundFX/bombdrop", "bombdrop");
            SoundFxLibrary.AddToLibrary("SoundFX/bombwhistle", "bombwhistle");
            SoundFxLibrary.AddToLibrary("SoundFX/hitplane1", "hitplane1");
            SoundFxLibrary.AddToLibrary("SoundFX/hitplane2", "hitplane2");
            SoundFxLibrary.AddToLibrary("SoundFX/refill", "refill");

            player1 = new PlayerAirplane();
            // Add instruments
            throttleMeter = new Instrument("instrument", new Vector2(150, ScreenHeight), 0f, 7.5f, 0.6f, "throttle", "Throttle", player1);
            _instruments.Add("throttleMeter", throttleMeter);

            airspeedMeter = new Instrument("instrument", new Vector2(270, ScreenHeight), 0f, 13f, 0.6f, "linearvelocity", "Airspeed", player1);
            _instruments.Add("airspeedMeter", airspeedMeter);

            foreach (Instrument inst in _instruments.Values)
            {
                inst.LoadContent();
            }
            // !Add instruments

            SkyGradient skyGradient = new SkyGradient("skygradient");
            SceneGraphManager.AddObject(skyGradient);

            SceneGraphManager.AddObject(player1);
            _ammoDisplay = new AmmoDisplay((ProjectileWeapon)player1.ProjectileWeapon, (BombWeapon)player1.BombWeapon);
            _ammoDisplay.LoadContent();
            _cobraMeter = new CobraMeter(player1);

            SceneGraphManager.LoadContent();
            ParticleManager.LoadContent();
        }