Пример #1
0
    public void AssignInventory(ProjectileInventory shotInventory)
    {
        // rebuild inventory list each time
        foreach (ProjectileKind projectileKind in Enum.GetValues(typeof(ProjectileKind)))
        {
            if (ammoRegistry.ContainsKey(projectileKind))
            {
                Destroy(ammoRegistry[projectileKind].gameObject);
                Remove(ammoRegistry[projectileKind]);
                ammoRegistry.Remove(projectileKind);
            }
        }

        // loop through all shot types
        foreach (ProjectileKind projectileKind in Enum.GetValues(typeof(ProjectileKind)))
        {
            // if we have available shots...
            var available = shotInventory.GetAvailable(projectileKind);
            if (available > 0)
            {
                AmmoInfoController ammoInfo;
                // create new ammo info slot if required
                if (!ammoRegistry.TryGetValue(projectileKind, out ammoInfo))
                {
                    var ammoInfoGo = (GameObject)Instantiate(ammoInfoPrefab);
                    ammoInfo = ammoInfoGo.GetComponent <AmmoInfoController>();
                    ammoRegistry[projectileKind] = ammoInfo;
                    Add(ammoInfo);
                }
                // update ammo count
                ammoInfo.AssignAmmo(projectileKind, available);
            }
        }
        SetSelected(lastSelectedShot);
    }
Пример #2
0
    void Awake()
    {
        //Debug.Log("TankController Awake: isServer: " + isServer + " isLocalPlayer: " + isLocalPlayer);
        // lookup/cache required components
        rb            = GetComponent <Rigidbody>();
        shotInventory = GetComponent <ProjectileInventory>();

        // disable rigidbody physics until activated by turn manager
        SetPhysicsActive(false);

        // create underlying model
        CreateModel();

        // let there be sound!

        /*
         * tankSound = (AudioClip)Resources.Load("TankSound/" + tankSoundKind);
         * turretHorizontalMovementSound = (AudioClip)Resources.Load("TankSound/" + TankSoundKind.tank_movement_LeftRight_LOOP_01);
         * turretVerticalMovementSound = (AudioClip)Resources.Load("TankSound/" + TankSoundKind.tank_movement_UpDown_LOOP_01);
         * tankPowerSound = (AudioClip)Resources.Load("TankSound/" + TankSoundKind.tank_power_UpDown_LOOP);
         * tankHorizontalMovementAudioSource = gameObject.AddComponent<AudioSource>() as AudioSource;
         * tankHorizontalMovementAudioSource.loop = true;
         * tankHorizontalMovementAudioSource.clip = turretHorizontalMovementSound;
         *
         * secondaryAudioSource = new GameObject("secondaryAudioSource");
         * secondaryAudioSource.transform.SetParent(transform);
         * tankVerticalMovementAudioSource = secondaryAudioSource.AddComponent<AudioSource>() as AudioSource;
         * tankVerticalMovementAudioSource.loop = true;
         * tankVerticalMovementAudioSource.clip = turretVerticalMovementSound;
         */
        charVoice = BarkManager.self.AssignCharVoice();

        /*
         * powerAudioSource = new GameObject("powerAudioSource");
         * powerAudioSource.transform.SetParent(transform);
         * tankPowerAudioSource = powerAudioSource.AddComponent<AudioSource>() as AudioSource;
         * tankPowerAudioSource.loop = true;
         * tankPowerAudioSource.clip = tankPowerSound;
         */

        virusParticlesGO = (GameObject)GameObject.Instantiate(Resources.Load("Spawn/" + SpawnKind.InfectedParticles));
        virusParticlesGO.transform.SetParent(transform);
        virusParticlesGO.name = "E-Virus";
        virusParticles        = virusParticlesGO.GetComponentInChildren <ParticleSystem>();
        playerHealth          = GetComponent <Health>();
    }