Esempio n. 1
0
 void Start()
 {
     shipClass = GetComponent <ShipClass>();
     camera    = Camera.main;
     movement  = GetComponent <MovementController>();
     weapons   = GetComponentInChildren <WeaponsController>();
 }
Esempio n. 2
0
    public bool SetPilot(GameObject player)
    {
        if (pilot)
        {
            return(false);
        }

        GUIHandler.instance.ToggleGUI();

        hull = transform.Find("Hull").gameObject;

        pilot        = player;
        InputManager = pilot.GetComponent <InputManager>();

        pilotCamController         = GetComponent <PilotCamController>();
        pilotCamController.enabled = true;
        pilotCamController.SetCamera(pilot.transform.Find("MainCamera").gameObject);

        pilot.transform.localPosition = pilotPosition.transform.position;
        pilot.transform.rotation      = transform.rotation;
        pilot.transform.SetParent(hull.transform);

        weaponsController = GetComponent <WeaponsController>();
        weaponsController.InputManager = InputManager;
        weaponsController.enabled      = true;

        return(true);
    }
Esempio n. 3
0
 private void Start()
 {
     Instance             = this;
     _controllers         = new GameObject("Controllers");
     _objManager          = GetComponent <ObjManager>();
     _otherStuffCollector = GetComponent <OtherStuffCollector>();
     _inputController     = _controllers.AddComponent <InputController>();
     _weaponsController   = _controllers.AddComponent <WeaponsController>();
     _botsControlCenter   = _controllers.AddComponent <BotsControlCenter>();
     _spawnController     = _controllers.AddComponent <SpawnController>();
 }
Esempio n. 4
0
        private void Start()
        {
            EntityManager.Instance.RegisterCar(this);

            UpdateEngineSounds();

            Transform firstPersonTransform = _transform.Find("Chassis/FirstPerson");

            WeaponsController  = new WeaponsController(this, Vcf, firstPersonTransform);
            SpecialsController = new SpecialsController(Vcf, firstPersonTransform);
        }
Esempio n. 5
0
    void Start()
    {
        myInfo            = GetComponent <UnitInfo>();
        weaponsController = GetComponent <WeaponsController>();
        myRigidbody       = GetComponent <Rigidbody>();

        if (HUDController.Instance != null)
        {
            HUDController.Instance.SetThrottleTextPercentage(throttlePercentage);
        }
    }
Esempio n. 6
0
 private void Start()
 {
     Instance = this;
     _controllersGameObject = new GameObject {
         name = "Controllers"
     };
     _inputController      = _controllersGameObject.AddComponent <InputController>();
     _flashlightController = _controllersGameObject.AddComponent <FlashlightController>();
     _weaponsController    = _controllersGameObject.AddComponent <WeaponsController>();
     _objectManager        = GetComponent <ObjectManager>();
 }
 void Awake()
 {
     if (!weaponsController)
     {
         weaponsController = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Esempio n. 8
0
        public PlayerFactory(Engine engine, SignalBus signalBus, DiContainer container, WeaponsController weaponsController)
        {
            _weaponsController = weaponsController;
            _container         = container;
            _signalBus         = signalBus;
            _engine            = engine;
            container.BindMemoryPool <PlayerView, PlayerView.Pool>()
            .WithInitialSize(PollCount)
            .FromComponentInNewPrefabResource("PlayerEntity")
            .UnderTransformGroup("Pool_PlayerEntity");

            _pool = container.Resolve <PlayerView.Pool>();
        }
Esempio n. 9
0
    private void Start()
    {
        sr   = GetComponent <SpriteRenderer>();
        pc2d = GetComponent <PolygonCollider2D>();
        wc   = GetComponent <WeaponsController>();
        pm   = GetComponent <PlayerMovement>();
        ps   = GetComponentInChildren <ParticleSystem>();

        playerCurrentHealth = playerStartHealth;
        gc            = FindObjectOfType <GameController>();
        startPosition = new Vector3(transform.position.x,
                                    transform.position.y,
                                    transform.position.z);
    }
Esempio n. 10
0
    public static void ResetPlayerStats()
    {
        singletonInstance.playerObject.transform.position = singletonInstance.offscreenPosition;
        string param = PlayerController.GetSizeParameter();

        SetAnimationParameter(param, false);
        ResetPlayerSpeed();
        ResetSizeParameter();
        WeaponsController.ResetShellSpeed();

        singletonInstance.gameObject.GetComponent <PlayerController>().enabled  = false;
        singletonInstance.gameObject.GetComponent <WeaponsController>().enabled = false;
        singletonInstance.playerObject.GetComponent <Rigidbody2D>().velocity    = Vector2.zero;
        singletonInstance.playerObject.GetComponent <Animator>().enabled        = false;
    }
Esempio n. 11
0
    IEnumerator PickUp(Collider2D player)
    {
        // increase the fire rate for a period then revert back
        WeaponsController wc = player.GetComponent <WeaponsController>();

        wc.firingRate = fireRateIncrease;

        GetComponent <Collider2D>().enabled        = false;
        GetComponent <SpriteRenderer>().enabled    = false;
        GetComponent <PolygonCollider2D>().enabled = false;

        yield return(new WaitForSeconds(2.0f));

        wc.firingRate = fireRateNormal;
        Destroy(gameObject);
    }
Esempio n. 12
0
    // Inizializza la navetta
    public void Init()
    {
        _shipData = data.shipData;

        // Rimuovo tutti gli elementi all'interno del model container
        // Nel caso avessi già instanziato una navetta precedentemente
        foreach (Transform t in modelContainer.transform)
        {
            Destroy(t.gameObject);
        }

        GameObject ship = GameObject.Instantiate(_shipData.shipPrefab, modelContainer.transform);

        ship.name = _shipData.modelName;

        // Se la navetta possiede un renderer, procedo alla sostituzione dei colori
        if (ship.GetComponentInChildren <Renderer> () != null)
        {
            // Recupero l'elenco dei materiali della navetta
            Material[] shipMaterials = ship.GetComponentInChildren <Renderer> ().materials;

            // Ciclo sui colori all'interno del mio ScriptableObject
            for (int i = 0; i < _shipData.shipColors.Length; i++)
            {
                // Se l'indice del colore che sto considerando è presente nella lista
                // dei materiali...
                if (i <= shipMaterials.Length)
                {
                    // ...assegno il colore
                    shipMaterials [i].color = _shipData.shipColors [i];
                }
            }
        }

        _weaponsController = gameObject.GetComponent <WeaponsController> ();
        if (_weaponsController != null)
        {
            _weaponsController.Init(data.weaponsData);
        }

        _enginesController = gameObject.GetComponent <EnginesController> ();
        if (_enginesController != null)
        {
            _enginesController.Init(data.enginesData);
        }
    }
Esempio n. 13
0
        public bool Execute(string[] commandParams, WeaponsController weaponsController)
        {
            var commandName = commandParams[0];

            switch (commandName)
            {
            case "Create":
            {
                weaponsController.CreateWeapon(commandParams.Skip(1).ToArray());
                return(false);
            }

            case "Add":
            {
                var gemParams   = commandParams[3];
                var socketIndex = int.Parse(commandParams[2]);
                var weaponName  = commandParams[1];
                weaponsController.AddGem(gemParams, socketIndex, weaponName);
                return(false);
            }

            case "Remove":
            {
                var weaponName  = commandParams[1];
                var socketIndex = int.Parse(commandParams[2]);
                weaponsController.RemoveGem(socketIndex, weaponName);
                return(false);
            }

            case "Print":
            {
                var weaponName = commandParams[1];
                weaponsController.PrintWeapon(weaponName);
                return(false);
            }

            case "END":
            {
                weaponsController.Print();
                return(true);
            }

            default:
                throw new ArgumentException("Invalid Command Name!");
            }
        }
Esempio n. 14
0
    public static void UpdateAmmoDisplay()
    {
        for (int i = 0; i < singletonInstance.shellDisplay.Count; i++)
        {
            if (isReloading[i] == 0)
            {
                singletonInstance.shellDisplay[i].GetComponent <RawImage>().texture = singletonInstance.availableShell;
                singletonInstance.shellDisplay[i].GetComponent <RawImage>().color   = new Color32(255, 255, 255, 255);
            }
        }

        for (int i = singletonInstance.shellDisplay.Count - 1; i > WeaponsController.GetCurrentMaxAmmo() - 1; i--)
        {
            singletonInstance.shellDisplay[i].GetComponent <RawImage>().texture = singletonInstance.disabledShell;
            singletonInstance.shellDisplay[i].GetComponent <RawImage>().color   = new Color32(75, 75, 75, 255);
        }
    }
Esempio n. 15
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        var playerCol = collider.GetComponent <CharacterController2D>();

        if (playerCol)
        {
            Debug.Log("Player collided");

            ctrl = player.GetComponentInChildren <WeaponsController>();

            if (ctrl)
            {
                Debug.Log("Weapons controller");
                //ctrl.setRapidFire();
                Destroy(gameObject);
            }
        }
    }
Esempio n. 16
0
    private void GiveUpgrade(PlayerActor player)
    {
        _onPickUpCue?.Play();
        // Get weapons
        WeaponsController playerWeapons = player.GetComponent <WeaponsController>();

        if (Hand)
        {
            playerWeapons.Right.UpgradeWeapon(_rightWeaponUpgrade);
        }
        else
        {
            playerWeapons.Left.UpgradeWeapon(_leftWeaponUpgrade);
        }


        Active = false;
        _upgradeParticleSystem?.gameObject.SetActive(false);
    }
    float maxTargetLength = 10.0f; // Maximum amount of time to have a target before searching for a new one

    void Start()
    {
        myInfo            = GetComponent <UnitInfo>();
        weaponsController = GetComponent <WeaponsController>();
        myRigidbody       = GetComponent <Rigidbody>();
        target            = GetEasiestTarget();
        myHealth          = GetComponent <Health> ();

        phase     = 1;
        shieldsOn = true;
        boosted   = false;

        if (!UnitTracker.GetActiveUnits().Contains(this.gameObject))
        {
            UnitTracker.AddUnit(this.gameObject);
        }
        // set target on spawn
        messageTxt = GameObject.Find("MessageText").GetComponent <MessageTextController>();
        messageTxt.DisplayMessage("Their shields are too strong for our weapons. Try to find a weak point.");
    }
Esempio n. 18
0
        private void Explode()
        {
            _rigidBody.AddForce(Vector3.up * _rigidBody.mass * 5f, ForceMode.Impulse);

            CarInput carInputController = GetComponent <CarInput>();

            if (carInputController != null)
            {
                Destroy(carInputController);
            }

            AudioSource explosionSource = _cacheManager.GetAudioSource(_gameObject, "xcar");

            if (explosionSource != null)
            {
                explosionSource.volume = 0.9f;
                explosionSource.Play();
            }

            EngineRunning = false;
            Destroy(_engineLoopSound);
            Destroy(_engineStartSound);

            Movement.Destroy();
            Movement = null;
            AI       = null;

            WeaponsController  = null;
            SpecialsController = null;
            SystemsPanel       = null;
            GearPanel          = null;
            _compassPanel      = null;
            RadarPanel         = null;

            Destroy(transform.Find("FrontLeft").gameObject);
            Destroy(transform.Find("FrontRight").gameObject);
            Destroy(transform.Find("BackLeft").gameObject);
            Destroy(transform.Find("BackRight").gameObject);
        }
Esempio n. 19
0
        /// <summary>
        /// Init player, must be called before 'Start'
        /// </summary>
        public void Init()
        {
            MainCamera = GetComponentInChildren <Camera>();


            // player must be faced to world forward
            transform.forward = Vector3.forward;


            // init vehicle
            Vehicle = GetComponentInChildren <PlayerVehicle>(true);
            Debug.Assert(Vehicle != null, "There must be a 'PlayerVehicle' as child object", this);

            Vehicle.Init(this);
            steeringWheel = Vehicle.SteeringWheel;

            // init weapons
            weaponsController = GetComponentInChildren <WeaponsController>();
            weaponsController.SetOwner(this);

            SignToEvents();
        }
Esempio n. 20
0
    // called once when object is instantiated
    void Start()
    {
        myInfo            = GetComponent <UnitInfo>();
        weaponsController = GetComponent <WeaponsController>();
        myRigidbody       = GetComponent <Rigidbody>();

        // reference to head of turret for proper movement
        turretHead = this.gameObject.transform.GetChild(0).gameObject;

        // reference to radar on head of turret for proper movement;
        turretRadar = turretHead.transform.GetChild(0).gameObject;

        if (targetObject == null)
        {
            AcquireTarget();
        }

        // if target not specified assume you are targeting playerfighter1
        if (targetObject == null)
        {
            targetObject = GameObject.Find("PlayerFighter1");
        }
    }
Esempio n. 21
0
    IEnumerator DrawPixels()
    {
        int currentPixelRow = 0;

        ShellDisplay.isReloading[shellDisplayIndex] = 1; //this line is so that other shells now this one is reloading
        isCurrentlyLoading = true;                       //this is one is so that the coroutine just runs once

        //filling a part of the temporary texture with the target texture
        while (currentPixelRow < targetTexture.height)
        {
            //Debug.Log("currentPixel: " + currentPixelRow);
            for (int y = currentPixelRow; y < currentPixelRow + 1; y++)
            {
                for (int x = 0; x < tmpTexture.width; x++)
                {
                    tmpTexture.SetPixel(x, y, targetTextureColors[x, y]);
                }

                tmpTexture.Apply();
                gameObject.GetComponent <RawImage>().texture = tmpTexture;
            }
            currentPixelRow++;
            yield return(new WaitForSeconds(Time.deltaTime * reloadingTimeFactor));
        }

        isCurrentlyLoading = false;

        int ammo = WeaponsController.GetCurrentAmmo();

        WeaponsController.SetCurrentAmmo(ammo + 1);

        ShellDisplay.isReloading[shellDisplayIndex] = 0;
        WeaponsController.SetShellAsLoaded(shellDisplayIndex);

        ResetTextures();
        enabled = false;
    }
Esempio n. 22
0
    // Use this for initialization
    void Start()
    {
        turretHead = transform.Find("TurretHead").gameObject;
        wc         = GetComponent <WeaponsController>();

        if (isChildTurret)
        {
            GetComponent <UnitInfo>().TeamID = transform.parent.GetComponent <UnitInfo>().TeamID;
        }

        if (isInvulnerable)
        {
            GetComponent <CapsuleCollider>().enabled = false;
        }
        else
        {
            GetComponent <CapsuleCollider>().enabled = true;
        }

        if (blueMaterial != null && redMaterial != null)
        {
            Material chosenMaterial = blueMaterial;
            if (color == TurretColor.RED)
            {
                chosenMaterial = redMaterial;
            }

            Material[] mats = transform.Find("TurretBody").GetComponent <MeshRenderer>().materials;
            mats[1] = chosenMaterial;
            transform.Find("TurretBody").GetComponent <MeshRenderer>().materials = mats;

            mats    = transform.Find("TurretHead/Model").GetComponent <MeshRenderer>().materials;
            mats[0] = chosenMaterial;
            transform.Find("TurretHead/Model").GetComponent <MeshRenderer>().materials = mats;
        }
    }
Esempio n. 23
0
    float maxTargetLength = 10.0f; // Maximum amount of time to have a target before searching for a new one

    void Awake()
    {
        myInfo            = GetComponent <UnitInfo>();
        weaponsController = GetComponent <WeaponsController>();
        myRigidbody       = GetComponent <Rigidbody>();
    }
Esempio n. 24
0
 private void InitializeSingleton()
 {
     singletonInstance = this;
 }
Esempio n. 25
0
 public Engine()
 {
     this.weaponsController = new WeaponsController(new WeaponsDatabase());
     this.commandExecutor   = new CommandExecutor();
 }
Esempio n. 26
0
 public PresenterWeapons(SignalBus signalBus, WeaponsController weaponsController)
 {
     _weaponsController = weaponsController;
     _signalBus         = signalBus;
 }
Esempio n. 27
0
 private void Awake()
 {
     _statsController = GetComponent <StatsController>();
     _wpController    = GetComponent <WeaponsController>();
     _nextShoot       = 0;
 }
Esempio n. 28
0
 private void OnPlayerLaserFiredEvent(WeaponsController weapons)
 {
     // Move towards wherever the shot came from
     waypoint.position = weapons.transform.position;
 }
Esempio n. 29
0
 void GetShipComponents()
 {
     playerShipEngines = playerObject.GetComponentInChildren <Engines>();
     playerShipWeapons = playerObject.GetComponentInChildren <WeaponsController>();
 }
Esempio n. 30
0
        public bool Execute(string[] commandParams, WeaponsController weaponsController)
        {
            var commandName = commandParams[0];

            switch (commandName)
            {
            case "Create":
            {
                weaponsController.CreateWeapon(commandParams.Skip(1).ToArray());
                return(false);
            }

            case "Add":
            {
                var gemParams   = commandParams[3];
                var socketIndex = int.Parse(commandParams[2]);
                var weaponName  = commandParams[1];
                weaponsController.AddGem(gemParams, socketIndex, weaponName);
                return(false);
            }

            case "Remove":
            {
                var weaponName  = commandParams[1];
                var socketIndex = int.Parse(commandParams[2]);
                weaponsController.RemoveGem(socketIndex, weaponName);
                return(false);
            }

            case "Print":
            {
                var weaponName = commandParams[1];
                weaponsController.PrintWeapon(weaponName);
                return(false);
            }

            case "END":
            {
                return(true);
            }

                //case "Author":
                //    {
                //        Console.WriteLine($"Author: Pesho");
                //        return false;
                //    }

                //case "Revision":
                //    {
                //        Console.WriteLine($"Revision: 3");
                //        return false;
                //    }

                //case "Description":
                //    {
                //        Console.WriteLine($"Class description: Used for C# OOP Advanced Course - Enumerations and Attributes.");
                //        return false;
                //    }

                //case "Reviewers":
                //    {
                //        Console.WriteLine($"Reviewers: Pesho, Svetlio");
                //        return false;
                //    }

                //default:
                //    throw new ArgumentException("Invalid Command Name!");
                //    return true;
            }

            return(this.GetAttributeProperties(commandName));
        }