Inheritance: MonoBehaviour
Ejemplo n.º 1
0
    void Start()
    {
        GameObject shipControllerObject = GameObject.FindWithTag ("Player");
        if (shipControllerObject != null) {
            shipController = shipControllerObject.GetComponent<ShipController>();
        }

        if (shipController == null) {
            Debug.Log("Cannot find 'ShipController' object");
        }

        GameObject gameControllerObject = GameObject.FindWithTag ("GameController");
        if (gameControllerObject != null) {
            gameController = gameControllerObject.GetComponent<GameController>();
        }

        if (gameController == null) {
            Debug.Log ("Cannot find 'GameController' object");
        }

        dummyObject = GameObject.FindGameObjectWithTag ("DummyObject");
        gameObject.GetComponent<Rigidbody> ().velocity = transform.forward * speed;
        StartCoroutine (StartFiring ());
        abductionTime = Time.time + abductDelay;
    }
Ejemplo n.º 2
0
 public void init(string name, int id, float cooldown)
 {
     player = gameObject.GetComponent<ShipController>();
     this.captainName = name;
     this.id = id;
     this.cooldown = cooldown;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// This method will be called when the user selects a ship type to use. The ShipeType is passed as a parameter.
 /// </summary>
 public static void OnShipConfigMenuShipSelected(ShipController.ShipType type)
 {
     Assert.IsNotNull(ShipConfigMenuShipSelectedEvent);
     if (ShipConfigMenuShipSelectedEvent != null)
     {
         ShipConfigMenuShipSelectedEvent(type);
     }
 }
Ejemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     shipController = ShooterShip.GetComponent<ShipController>();
     lockWheel = LockWheel.GetComponent<MusicManager>();
     cameraScript = camera.GetComponent<CameraScript>();
     angle = 0;
     radius = lockWheel.radius;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShipControllerTest"/> class.
 /// </summary>
 public ShipControllerTest()
 {
     this.shipManager = new Mock<IShipManager>();
     this.shipCollection = new ListResult<Ship>();
     this.controller = new ShipController(this.shipManager.Object);
     this.controller.Request = new HttpRequestMessage();
     this.controller.Configuration = new HttpConfiguration();
 }
Ejemplo n.º 6
0
    private ShipController getShipController()
    {
        if(shipController == null) {
            shipController = (ShipController) GameObject.FindGameObjectWithTag("Ship").GetComponent(typeof(ShipController));
        }

        return shipController;
    }
Ejemplo n.º 7
0
 //####################################################################################################
 void Start()
 {
     _player = GameObject.FindWithTag("Ship").GetComponent<ShipController>();
     _camPos = Camera.main.transform;
     _hardnessIndicator = GetComponentInChildren<TextMesh>();
     _scoreSupply = hardness;
     _hardnessIndicator.text = hardness.ToString();
 }
Ejemplo n.º 8
0
        public Ship(AIController ai, GameEnvironment env)
            : base()
        {
            this.ai = ai;
            this.maxSpeed = 50.0f;
            this.maxTurn = 0.025f;

            shooter = new BulletEmitter(env, BulletEmitter.BulletStrength.Medium, IsFriendly());
            env.AddChild(shooter);
        }
Ejemplo n.º 9
0
 public void SelectShip(GameObject UISelected)
 {
     Debug.Log(UISelected.name);
     if(selected) {
       selected.Deselect();
     }
     selected = UISelected.GetComponent<ShipController>();
     selected.Select();
     Camera.main.GetComponent<MouseScrollPanZoom>().target = UISelected.transform;
 }
Ejemplo n.º 10
0
 public TestShip(float x, float y, float vx, float vy,GameEnvironment env)
 {
     LoadTexture(env.contentManager, "Sputnik");
     Registration = new Vector2(Texture.Width, Texture.Height) * 0.5f;
     CreateCollisionBody(env.CollisionWorld, BodyType.Dynamic, CollisionFlags.DisableSleep);
     AddCollisionCircle(Texture.Width * 0.5f, Vector2.Zero);
     Position = new Vector2(x, y);
     SetPhysicsVelocityOnce(new Vector2(vx, vy));
     controller = new PlayerController(env);
 }
Ejemplo n.º 11
0
 public void loadGame()
 {
     if (File.Exists(GameOptions.getSaveLoadPath()))
     {
         BinaryFormatter b = new BinaryFormatter();
         FileStream f = File.Open(GameOptions.getSaveLoadPath(), FileMode.Open);
         ShipModel sm = (ShipModel)b.Deserialize(f);
         shipController = new ShipController(sm);
     }
 }
 public void RequestDirectControl(ShipController a_controller)
 {
     if (m_player)
     {
         if (m_currentControlledShip)
         {
             m_currentControlledShip.SetControlType(CONTROLTYPE.AI);
         }
         m_currentControlledShip = a_controller;
         a_controller.SetControlType(CONTROLTYPE.DIRECT);
     }
 }
Ejemplo n.º 13
0
	// Use this for initialization
	void Start () {
        ship_controller = GameObject.Find("Ship").GetComponent<ShipController>();
        ab_sel_controller = GameObject.Find("bwPicker").GetComponent<asc_bw>();

        numOfDifferentEnemies = 3;
        enemy_prefabs = new GameObject[numOfDifferentEnemies];
        enemy_prefabs[0] = diver_prefab;
        enemy_prefabs[1] = sprinter_prefab;
        enemy_prefabs[2] = turret_prefab;

        time_between_waves_timer = time_between_waves_length;
	}
Ejemplo n.º 14
0
	void Start() {
		self = this;
		root = GameObject.Find("PlayerShipRoot");

		rigidbody = GetComponent<Rigidbody>();
		originalDrag = drag;
		rigidbody.drag = originalDrag;
		rigidbody.angularDrag = angularDrag;
		rigidbody.maxAngularVelocity = maxAngularVelocity;

		
	}
Ejemplo n.º 15
0
    // Use this for initialization
    void Start()
    {
        es = GameObject.Find("Main Camera").GetComponent<EnemySpawner>();
        ship_controller = GameObject.Find("Ship").GetComponent<ShipController>();

        // Add all implemented abilities to list
        mods.Add("turret");
        mods.Add("sprinter");
        mods.Add("spinner");
        mods.Add("missle");
        mods.Add("swapSticks");
        mods.Add("inverseWorld");

        UI.SetActive(false);
    }
Ejemplo n.º 16
0
    void CmdDestroyPlayerShip()
    {
        //Null check
        if (shipObject == null)
        {
            return;
        }

        //Ship controller
        ShipController shipController = shipObject.GetComponent <ShipController>();

        shipController.ExitShip();

        //Destroy ship object across the network
        NetworkServer.Destroy(shipObject);
    }
Ejemplo n.º 17
0
    public override float ProcessForFrame(ShipController ship, float elapsedTime)
    {
        var shipBody = ship.GetComponent <Rigidbody2D>();

        var powerUsed = 0f;

        IsActivated = false;
        if (Input.GetKey(controlKey) && ship.IsWorking)
        {
            shipBody.AddForceAtPosition(transform.rotation * (power * Vector2.up), transform.position);
            powerUsed   = activePowerUsage * elapsedTime;
            IsActivated = true;
        }

        return(powerUsed);
    }
Ejemplo n.º 18
0
    void SetUpControllable()
    {
        PlayerGameObject = Instantiate(Resources.Load("Prefab/Ship") as GameObject);

        ShipControls = (ShipController)PlayerGameObject.GetComponent(typeof(ShipController));

        TargetingCursor = Instantiate(Resources.Load("Prefab/Targeting Cursor") as GameObject);

        TargetControls = (TargetingCursorController)TargetingCursor.GetComponent(typeof(TargetingCursorController));

        ShipControls.AddSubObject("Prefab/Turret", new Vector3(0, 1, 1));

        ShipControls.AddSubObject("Prefab/Turret", new Vector3(0, 1, -1));

        ShipControls.AddSubObject("Prefab/Turret", new Vector3(0, 1, 2));
    }
Ejemplo n.º 19
0
        public void Update(float deltaTime)
        {
            for (int i = 0; i < ships.Count; i++)
            {
                ShipController ship = ships[i];

                /*if (ship.IsDestroyed)
                 * {
                 *  ships.RemoveAt(i);
                 *  i--;
                 *  lootController.AddLoot(ship.DroppingExperience, ship.Position);
                 * }
                 * else*/
                ships[i].Update();
            }
        }
Ejemplo n.º 20
0
    private void Shoot(Vector3 position)
    {
        ShipController controller = owner.GetComponent <ShipController>();

        transform.forward = (position - transform.position).normalized;
        var projectile = Instantiate(controller.bulletPrefab, firePos.position, firePos.rotation);
        BulletController bulletController = projectile.AddComponent <BulletController>();

        bulletController.owner = owner;
        bulletController.SetColor(controller.shipColor);
        bulletController.damage = controller.damage;
        projectile.GetComponent <TrailRenderer>().time = 0.15f;
        projectile.GetComponent <Rigidbody>().AddForce(projectile.transform.forward * controller.bulletSpeed / 2, ForceMode.VelocityChange);
        Destroy(projectile, 5.0f);
        lastShot = 1.0f;
    }
Ejemplo n.º 21
0
    void Start()
    {
        owningObject = gameObject.transform.parent.gameObject;

        owningShip = owningObject.GetComponent <ShipController>();

        fireTime = Time.timeSinceLevelLoad;
        if (projectileType != ProjectileType.missile)
        {
            range = projectileSpeed * lifetime;
        }
        else
        {
            range = 10000000f;
        }
    }
    public void SelectShip(ShipController ship)
    {
        _selectedShip = ship;

        var _mob = ship.GetComponent <MobileObjectController>();

        TurnSlider.value  = _mob.TurnProportion;
        MinTurnLabel.text = _mob.MaxTurn.ToString("F0");
        MaxTurnLabel.text = _mob.MaxTurn.ToString("F0");

        SpeedSlider.value  = _mob.SpeedProportion;
        MinSpeedLabel.text = _mob.GetMinSpeed().ToString("F1");
        MaxSpeedLabel.text = _mob.GetMaxSpeed().ToString("F1");

        ShipControlsPanel.SetActive(true);
    }
Ejemplo n.º 23
0
    //refreshes enemy info, or hides everything if there is no enemy
    void Update()
    {
        if (gcScript.GetEnemy())
        {
            enemyInfo.SetActive(true);

            currentEnemy         = gcScript.GetEnemy().GetComponent <ShipController>();
            healthText.text      = currentEnemy.GetHealth() + " / " + currentEnemy.GetMaxHealth();
            healthBar.fillAmount = (float)currentEnemy.GetHealth() / currentEnemy.GetMaxHealth();
            nameText.text        = currentEnemy.name;
        }
        else
        {
            enemyInfo.SetActive(false);
        }
    }
Ejemplo n.º 24
0
 private void CheckMoveInputs(ShipController controller)
 {
     if (Input.GetKey(KeyCode.W))
     {
         controller.OnMoveEmitted();
     }
     if (Input.GetKey(KeyCode.A))
     {
         controller.OnRotateEmitted(1);
     }
     if (Input.GetKey(KeyCode.D))
     {
         controller.OnRotateEmitted(-1);
     }
     return;
 }
Ejemplo n.º 25
0
    // Override this method to provide extra functionality when the player enters a trigger.
    public override void OnTriggerEnter(Collider other)
    {
        ShipController controller = other.transform.parent.GetComponent <ShipController>();

        // When a shipController enters the radar collider
        if (controller != null)
        {
            Assert.IsTrue(isLocalPlayer);
            Assert.IsFalse(Network.isServer);
            HandleShipEnterVecinity(controller);
        }
        else
        {
            base.OnTriggerEnter(other);
        }
    }
Ejemplo n.º 26
0
    private void ServerRecieveMovementVector(NetworkMessage message)
    {
        StringMessage msg = new StringMessage
        {
            value = message.ReadMessage <StringMessage>().value
        };

        string[] deltas = msg.value.Split('|');

        ShipController shipController = shipControllers[message.conn.connectionId];

        if (shipController.gameObject)
        {
            shipControllers[message.conn.connectionId].Move(Convert.ToSingle(deltas[0]), Convert.ToSingle(deltas[1]));
        }
    }
Ejemplo n.º 27
0
 void LateUpdate()
 {
     if (target == null)
     {
         GameObject temp = GameObject.FindWithTag("Player");
         if (temp != null)
         {
             ship   = temp.GetComponent <ShipController>();
             target = ship.transform;
         }
     }
     else
     {
         transform.position = Vector3.Lerp(transform.position, new Vector3(target.position.x, transform.position.y, -10), 0.8f);
     }
 }
Ejemplo n.º 28
0
    public void Break(GameObject _source)
    {
        int            sourceId         = -1;
        ShipController sourceController = GetOwner(_source);

        if (sourceController != null)
        {
            sourceId = sourceController.playerId;
        }

        GameEventPlayerDeath e = new GameEventPlayerDeath(sourceId, this.playerId);

        gameManager.NotifyEvent(e);

        //Respawn();
    }
Ejemplo n.º 29
0
    void Start()
    {
        shoot   = GetComponent <AudioSource>();
        sc      = GetComponentInParent <ShipController>();
        mypitch = shoot.pitch;

        for (int i = 0; i < transform.childCount; ++i)
        {
            Transform child = tilt.GetChild(i);

            if (child.name == "BulletSpawnPoint")
            {
                bulletSpawns.Add(child);
            }
        }
    }
Ejemplo n.º 30
0
    // Pool de bombas, TODO falta retomar la idea del pool en modo multiplayer
    //BombFactory bombFactory;

    void Awake()
    {
        collider = GetComponent <CapsuleCollider>();

        rigidbody = GetComponent <Rigidbody>();
        // Para que el rigidbody no deje de recibir eventos mientras esta inmovil
        rigidbody.sleepThreshold = 0.0f;

        // Para comprobar cuando se toca el suelo
        groundCheck = transform.Find("GroundCheck").transform;

        // Para comprobar si se toca un obstaculo
        obstacleCheck = transform.Find("ObstacleCheck").transform;

        // Objeto que manipula las animaciones
        anim = transform.Find("CharacterSprite").GetComponent <Animator>();

        // Control de la nave
        shipController = GameObject.Find("Ship").GetComponent <ShipController>();

        currentWeaponPrefab = shotPrefab;
        // Inicializando posiciones de cañon
        canonIdleSpawn            = transform.Find("CanonAiming/CanonIdleSpawn").gameObject;
        canonAimingFrontSpawn     = transform.Find("CanonAiming/CanonAimingFrontSpawn").gameObject;
        canonAimingUpFrontSpawn   = transform.Find("CanonAiming/CanonAimingUpFrontSpawn").gameObject;
        canonAimingDownFrontSpawn = transform.Find("CanonAiming/CanonAimingDownFrontSpawn").gameObject;
        canonAimingUp             = transform.Find("CanonAiming/CanonAimingUp").gameObject;

        canonAimingFrontSpawnAir     = transform.Find("CanonAimingAir/CanonAimingFrontSpawn").gameObject;
        canonAimingUpFrontSpawnAir   = transform.Find("CanonAimingAir/CanonAimingUpFrontSpawn").gameObject;
        canonAimingDownFrontSpawnAir = transform.Find("CanonAimingAir/CanonAimingDownFrontSpawn").gameObject;
        canonAimingUpAir             = transform.Find("CanonAimingAir/CanonAimingUp").gameObject;
        canonAimingDownSpawnAir      = transform.Find("CanonAimingAir/CanonAimingDownSpawn").gameObject;

        canonAimingFrontSpawnKnees     = transform.Find("CanonAimingKnees/CanonAimingFrontSpawn").gameObject;
        canonAimingUpFrontSpawnKnees   = transform.Find("CanonAimingKnees/CanonAimingUpFrontSpawn").gameObject;
        canonAimingDownFrontSpawnKnees = transform.Find("CanonAimingKnees/CanonAimingDownFrontSpawn").gameObject;
        canonAimingUpSpawnKnees        = transform.Find("CanonAimingKnees/CanonAimingUpSpawn").gameObject;

        //bombFactory = GameObject.Find("BombFactory").GetComponent<BombFactory>();

        // Cargando sonidos
        baseShotSound = Resources.Load("Sounds/BaseShot_clean", typeof(AudioClip)) as AudioClip;
        bombSound     = Resources.Load("Sounds/Bomb", typeof(AudioClip)) as AudioClip;

        playerIdText = transform.GetComponentInChildren <TextMesh>();
    }
Ejemplo n.º 31
0
    private void OnTriggerEnter(Collider collider)
    {
        if (isInitialized)
        {
            GameObject collidedObject    = collider.gameObject;
            string     collidedObjectTag = collidedObject.tag;

            #region Collision with ships
            if (collidedObjectTag == shipTag)
            {
                if (isControlledByServer)
                {
                    ShipController collidedShip = collidedObject.GetComponentInParent <ShipController>();
                    collidedShip.TakeDamage(projectileDamage, ownerIndex);
                    em.BroadcastProjectileHitShip(ownerIndex, projectileIndex, collidedShip.GetIndex(), projectileDamage);
                    DestroyOnHit();
                }
                else
                {
                    Debug.Log("Projectile is not controlled by server, ignoring ship collision");
                }
            }
            #endregion

            #region Collision with environment
            else if (collidedObjectTag == environmentTag)
            {
                if (!isPersistingProjectile && projectileRicochetCounter < projectileRicochetNumber && !ricohetOnCooldown)
                {
                    projectileRicochetCounter++;

                    transform.rotation = Quaternion.LookRotation(Ricochet());

                    ricochetCooldownTimer = Mathf.RoundToInt(projectileRicochetCooldown / Time.fixedDeltaTime);
                    ricohetOnCooldown     = true;
                }
                else
                {
                    if (!isPersistingProjectile)
                    {
                        DestroyOnHit();
                    }
                }
            }
            #endregion
        }
    }
Ejemplo n.º 32
0
    private ShipController AddShip(int ownerID, Vector3 spawnPosition, Quaternion qRot, int shipID)
    {
        GameObject sObj = (GameObject)Instantiate(shipPrefab, spawnPosition, qRot);

        ShipController sc = sObj.GetComponent <ShipController>();
        Chunk          spaceShipVisualChunk = sc.visualHolder.GetComponentInChildren <Chunk>();

        // TODO
        // Update to set function
        spaceShipVisualChunk.standardVoxelModel = standardVoxelSpaceShipModels[ownerID % standardVoxelSpaceShipModels.Count];
        spaceShipVisualChunk.LoadChunk();
        spaceShipVisualChunk.GenerateChunk();

        if (serverMode)
        {
            foreach (MeshCollider c in sObj.GetComponentsInChildren <MeshCollider>())
            {
                c.enabled = false;
            }
        }

        shipControllers.Add(sc);
        sc.shipOwner = ownerID;
        sc.shipID    = shipID;

        if (shipIDTracker <= shipID)
        {
            shipIDTracker = shipID + 1;
        }

        if (playerID > -1 && sc.shipOwner != playerID)
        {
            //sc.GetComponent<Renderer>().material.color = Color.red;
        }

        if (serverMode)
        {
            foreach (Renderer r in sc.GetComponentsInChildren <Renderer>())
            {
                r.enabled = false;
            }
        }

        gamePieces.Add(sObj);

        return(sc);
    }
Ejemplo n.º 33
0
    public void SetGameState(GameState state)
    {
        List <ShipState> ss = state.ships;

        // CHECK IF SHIP EXISTS
        // IF NOT CREATE SHIP
        // UPDATE SHIP STATE

        foreach (ShipState s in ss)
        {
            ShipController sc = GetShipController(s.shipID);

            if (sc == null)
            {
                // CREATE SHIP
                Quaternion qRot = new Quaternion();
                qRot.eulerAngles.Set(s.rotation.x, s.rotation.y, s.rotation.y);
                sc = AddShip(s.owner, s.position, qRot, s.shipID);
            }

            sc.SetShipState(s);
        }

        foreach (ShipController sc in shipControllers.ToArray())
        {
            bool exists = false;
            foreach (ShipState s in ss)
            {
                if (s.shipID == sc.shipID)
                {
                    exists = true;
                    break;
                }
            }

            if (!exists)
            {
                ExplodeShip(sc);
            }
        }

        turn      = state.turn;
        turnTimer = state.turnTimer;

        // SET CMDS
        // TODO
    }
Ejemplo n.º 34
0
    public void RemoveShip(ShipController shipController)
    {
        RectTransform rectTransform = gameObject.GetComponent <RectTransform>();

        rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x,
                                              rectTransform.sizeDelta.y - 30);

        foreach (ShipListEntryController entry in entries)
        {
            if (entry.shipController == shipController)
            {
                Destroy(entry.gameObject);
                entries.Remove(entry);
                return;
            }
        }
    }
Ejemplo n.º 35
0
    public override void OnStartLocalPlayer()
    {
        // Asignar el seguimiento de la camara al jugador local
        smoothFollow = Camera.main.GetComponent <SmothFollow>();
        smoothFollow.cameraTarget = transform.Find("CameraTarget");
        smoothFollow.enabled      = true;

        // Se inicializan los scripts dentro del controlador del chat
        chatController = GetComponent <ChatController>();
        chatController.characterMovement = GetComponent <CharacterMovement>();
        chatController.characterHealth   = GetComponent <CharacterHealth>();

        shipController = GameObject.Find("Ship").GetComponent <ShipController>();
        shipController.characterMovement = GetComponent <CharacterMovement>();

        GameObject.Find("NetworkManager").GetComponent <NetworkManagerHUD>().showGUI = false;
    }
Ejemplo n.º 36
0
    void OnDeath(ShipController instance)
    {
        CurrentMode = Mode.FinalScore;
        if (instance.ShipState == ShipController.State.Dead)
        {
            msInstance.finalScoreText.text = ShipController.Instance.Score.ToString();

            // Grab the best score
            int bestScore = PlayerPrefs.GetInt("bestScore", 0);
            if (ShipController.Instance.Score > bestScore)
            {
                bestScore = ShipController.Instance.Score;
                PlayerPrefs.SetInt("bestScore", bestScore);
            }
            msInstance.bestScoreText.text = bestScore.ToString();
        }
    }
Ejemplo n.º 37
0
    private void StartGame()
    {
        gameState              = GameState.RUNNING;
        startGameText.enabled  = false;
        sfxCreditsText.enabled = false;
        asteroidCountTracker   = 0;
        shipReference          = Instantiate(ship);
        shipController         = shipReference.GetComponent <ShipController>();

        Asteroid[] asteroids = FindObjectsOfType <Asteroid>();
        for (int i = 0; i < asteroids.Length; i++)
        {
            Destroy(asteroids[i].gameObject);
        }

        InstantiateNewWave();
    }
Ejemplo n.º 38
0
    private ShipController GetWinner()
    {
        int            winnerScore = int.MinValue;
        ShipController winner      = null;

        foreach (ShipController player in gameManager.Players.Values)
        {
            int id    = player.playerId;
            int score = scoreTracker.GetScore(id);
            if (score > winnerScore)
            {
                winnerScore = score;
                winner      = player;
            }
        }
        return(winner);
    }
Ejemplo n.º 39
0
    // Use this for initialization
    void Start()
    {
        shipController = gameObject.GetComponent<ShipController>();

        //Set Target
        target = GameObject.FindGameObjectWithTag("Player");

        //Get player level
        var playerLevels = target.GetComponent<ShipController>().GetShipLevel();

        int totalLevel = 0;

        foreach (var level in playerLevels)
        {
            totalLevel += level;
        }

        //Generate Ship level based on player level
        int[] shipLevels = new int[12];

        for (int i = 0; i < totalLevel; i++)
        {
            //Add level to random attribute
            var number = Random.Range(0, 11);

            //if this attribute level max?
            if (shipLevels[number] < 4)
            {
                //No
                shipLevels[number]++;
            }
            else
            {
                //Yes, lose this point
                continue;
            }
        }

        //Generate the Enemy ship
        shipController.LoadShip(shipLevels);

        //Register the Dead Event
        shipController.Dead += OnDead;

        CalculateShipMoveParameters();
    }
Ejemplo n.º 40
0
    // Use this for initialization
    void Start()
    {
        waveRecorder = GameObject.Find("Enemy_Wave").GetComponent <WaveRecorder>();

        float depth = transform.position.z - Camera.main.transform.position.z;

        bottomLeftBoundary = Camera.main.ViewportToWorldPoint(new Vector3(0f, 0.3f, depth));
        topRightBoundary   = Camera.main.ViewportToWorldPoint(new Vector3(1f, 1f, depth));
        xMin = bottomLeftBoundary.x + xPadding;
        xMax = topRightBoundary.x - xPadding;
        yMin = bottomLeftBoundary.y + yPadding;
        yMax = topRightBoundary.y - yPadding;

        shipController = GameObject.Find("Player_Ship").GetComponent <ShipController>();

        SpawnEnemies();
    }
Ejemplo n.º 41
0
    public void Infected()
    {
        if (ship != null && Vector3.Distance(transform.position, ship.transform.position) > 2f)
        {
            Vector3 rbcPos = transform.position;

            Vector3 targetPos = ship.transform.position;

            Vector3 dir = targetPos - rbcPos;
            dir.Normalize();

            transform.Translate(dir * moveVel * Time.deltaTime, Space.World);
        } else if (ship == null)
        {
            ship = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren<ShipController>();
        }
    }
Ejemplo n.º 42
0
    // Use this for initialization
    void Start()
    {
        shipController = gameObject.GetComponent <ShipController>();

        //Set Target
        target = GameObject.FindGameObjectWithTag("Player");

        //Get player level
        var playerLevels = target.GetComponent <ShipController>().GetShipLevel();

        int totalLevel = 0;

        foreach (var level in playerLevels)
        {
            totalLevel += level;
        }

        //Generate Ship level based on player level
        int[] shipLevels = new int[12];

        for (int i = 0; i < totalLevel; i++)
        {
            //Add level to random attribute
            var number = Random.Range(0, 11);

            //if this attribute level max?
            if (shipLevels[number] < 4)
            {
                //No
                shipLevels[number]++;
            }
            else
            {
                //Yes, lose this point
                continue;
            }
        }

        //Generate the Enemy ship
        shipController.LoadShip(shipLevels);

        //Register the Dead Event
        shipController.Dead += OnDead;

        CalculateShipMoveParameters();
    }
Ejemplo n.º 43
0
    // Use this for initialization
    void Start()
    {
        player    = GameObject.FindGameObjectWithTag("Player").GetComponent <ShipController>();
        goal      = GameObject.Find("MainGoal").GetComponent <GoalController>();
        popupWin  = GameObject.Find("popupWin");
        popupLose = GameObject.Find("popupLose");
        popupWin.gameObject.SetActive(false);
        popupLose.gameObject.SetActive(false);

        thisSceneName = SceneManager.GetActiveScene().name;
        thisLevel     = Int32.Parse(thisSceneName.Substring(6));

        audioSource        = GetComponent <AudioSource>();
        audioSource.clip   = bgm;
        audioSource.volume = 0.3f;
        audioSource.Play();
    }
Ejemplo n.º 44
0
    public static void PlaceShipRandomly(ShipModel ship)
    {
        List <int[]> positions = null;

        while (positions == null)
        {
            positions = ship.GetValidPositions();

            if (positions != null)
            {
                foreach (var position in positions)
                {
                    ShipController.PlaceShip(ship, position);
                }
            }
        }
    }
Ejemplo n.º 45
0
    void OnCollisionEnter2D(Collision2D collider)
    {
        ObstacleStats obstacleStats;

        if (collider.gameObject.tag.Equals("Obstacle"))
        {
            obstacleStats           = collider.gameObject.GetComponent <ObstacleStats>();
            obstacleStats.health   -= 1;
            forcefieldStats.health -= 1;
        }
        else if (collider.gameObject.tag.Equals("Ship"))
        {
            ShipController shipController = collider.gameObject.GetComponent <ShipController>();
            shipController.health  -= 1;
            forcefieldStats.health -= 1;
        }
    }
Ejemplo n.º 46
0
 // Use this for initialization
 void Awake()
 {
     shipController = GetComponent <ShipController> ();
     pathIndex      = startingIndex;
     Transform[] pathChilds = pathTransform.GetComponentsInChildren <Transform> ();
     path = new List <Vector3> ();
     for (int i = 0; i < pathChilds.Length; i++)
     {
         if (pathChilds [i] != pathTransform.transform)
         {
             path.Add(pathChilds [i].position);
         }
     }
     //debugSphere = GameObject.CreatePrimitive (PrimitiveType.Sphere);
     //Destroy (debugSphere.GetComponent<SphereCollider> ());
     //debugSphere.transform.localScale = Vector3.one * 10;
 }
Ejemplo n.º 47
0
 public string GetHUDInfo()
 {
     if (Object == null)
     {
         return("<Destroyed>");
     }
     if (Visible)
     {
         ShipController isShip = Object as ShipController;
         if (isShip != null)
         {
             return("Hull: " + isShip.Hull + "\nShields: " + isShip.Shields);
         }
         return("Type: " + Object.AttachmentType);
     }
     return("<Out of Range>");
 }
Ejemplo n.º 48
0
	private void TestSunk () {
		// Arrange
		shipController = Substitute.For <ShipController> ();
		shipController.size = 4;
		for (int i = 0; i < shipController.size; ++i) {
			GridSquare square = Substitute.For <GridSquare> ();
			square.hit = true;
			shipController.gridSquares.Add (square);
		}

		// Act
		shipController.updateSunk ();

		// Assert
		var generalComparer = AssertionComponent.Create<GeneralComparer> (CheckMethod.Update, gameObject, "ShipUnitTests.shipController.sunk", true);
		generalComparer.compareType = GeneralComparer.CompareType.AEqualsB;
	}
Ejemplo n.º 49
0
	// Use this for initialization
	void Start () {
        es = GameObject.Find("Main Camera").GetComponent<EnemySpawner>();
        ship_controller = GameObject.Find("Ship").GetComponent<ShipController>();
        rigid = gameObject.GetComponent<Rigidbody>();

        // Add all implemented abilities to list
        abilities.Add("Blink");
        abilities.Add("Time Slow");
        abilities.Add("Shield");
        abilities.Add("Invincible");
        abilities.Add("Hex Fire");
        abilities.Add("Fire Trail");
        abilities.Add("Invert");
        abilities.Add("Freeze");
        abilities.Add("Double Shot");
        abilities.Add("Paddle");

    }
Ejemplo n.º 50
0
    //####################################################################################################
    void Start()
    {
        _player = GameObject.FindGameObjectWithTag("Player");
        _ship = GameObject.FindWithTag("Ship").GetComponent<ShipController>();
        _pauseMenu = GameObject.FindWithTag("UpgradeMenu");

        _startResumeText = GetComponentInChildren<TextMesh>();
        _flashTimer = 0.0f;

        _startPosition = transform.position;

        //TODO: make each char a single cube, (START=5 , RESUME=6, find a workaround!)
        /* GameObject[] cubes = GetChildren
         * in mouseOver:
         * for(i)
         * cubes[i].position.z = sin(time + i)	// sine-jumping-cubes
        */
    }
Ejemplo n.º 51
0
	// Use this for initialization
	void Start () {
        es = GameObject.Find("Main Camera").GetComponent<EnemySpawner>();
        ship_controller = GameObject.Find("Ship").GetComponent<ShipController>();

        // Add all implemented abilities to list
        abilities.Add("Blink");
        abilities.Add("Time Slow");
        abilities.Add("Shield");
        abilities.Add("Invincible");
        abilities.Add("Hex Fire");
        abilities.Add("Fire Trail");

        mods.Add("turret");
        mods.Add("sprinter");
        mods.Add("spinner");
        mods.Add("missle");
        mods.Add("swapSticks");
        mods.Add("inverseWorld");

        UI.SetActive(false);
	}
 // Use this for initialization
 void Start()
 {
     shipController = gameObject.GetComponent<ShipController>();
 }
Ejemplo n.º 53
0
 public void HitShipTargetPoint(ShipController.ShipTarget aShipTarget, BombController.BombInfo aBombInfo)
 {
     GetComponent<PhotonView>().RPC("HitShipTargetPointRPC", PhotonTargets.AllBuffered, aShipTarget, aBombInfo);
 }
Ejemplo n.º 54
0
 void Start()
 {
     shipController = GetComponent<ShipController>();
 }
Ejemplo n.º 55
0
 // Use this for initialization
 void Start()
 {
     shipController = Ship.GetComponent<ShipController>();
     particleSystem = this.GetComponent<ParticleSystem>();
     originalStartSize = particleSystem.startSize;
 }
	public HealthSliderHealthObserver(ShipController sc)
	{
		shipController = sc;
		shipController.attachHealthObserver(this);
	}
Ejemplo n.º 57
0
 public void DestroyedShip(ShipController aShip, BombController.BombInfo aBombInfo)
 {
     GetComponent<PhotonView>().RPC("DestroyedShipRPC", PhotonTargets.AllBuffered, aShip.m_shipID, aBombInfo);
 }
Ejemplo n.º 58
0
        void HitShipTargetPointRPC(ShipController.ShipTarget aShipTarget, BombController.BombInfo aBombInfo)
        {
            ShipController.ShipTarget shipTarget = null;
            GameObject ship = null;

            for (int i = 0; i < m_spawnedShips.Count; i++)
            {
                if (m_spawnedShips[i].ContainsShipTarget(aShipTarget))
                {
                    shipTarget = m_spawnedShips[i].GetShipTarget(aShipTarget);
                    ship = m_spawnedShips[i].gameObject;
                    break;
                }
            }
            if (aBombInfo.m_shooter == PhotonNetwork.player)
            {
                m_bombsHit++;
                m_playerProperties["Score"] = (int)m_playerProperties["Score"] + GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().m_pointsForWeakpointDestruction;
            }

            if (PhotonNetwork.isMasterClient)
            {
                if ((int)aBombInfo.m_shooter.customProperties["Team"] == 1)
                {
                    m_team1Score += GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().m_pointsForWeakpointDestruction;
                    m_roomProperties = PhotonNetwork.room.customProperties;
                    m_roomProperties["Team1Score"] = m_team1Score;
                    PhotonNetwork.room.SetCustomProperties(m_roomProperties);
                }
                else if ((int)aBombInfo.m_shooter.customProperties["Team"] == 2)
                {
                    m_team2Score += GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().m_pointsForWeakpointDestruction;
                    m_roomProperties = PhotonNetwork.room.customProperties;
                    m_roomProperties["Team2Score"] = m_team2Score;
                    PhotonNetwork.room.SetCustomProperties(m_roomProperties);
                }
            }

            Plane[] frustrum = GeometryUtility.CalculateFrustumPlanes(Camera.main);
            if (GeometryUtility.TestPlanesAABB(frustrum, ship.transform.GetChild(0).GetChild(0).GetChild(0).GetComponent<Collider>().bounds))
            {
                GameObject.Find("PlayerController").GetComponent<PlayerController>().ShakeCamera(GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().m_weakpointIntensity, GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().m_shakeTime);
            }

            if (shipTarget == null) return;
            GameObject explosion = (GameObject)Instantiate((GameObject)Resources.Load("WeakpointExplosion"), shipTarget.m_position.position, shipTarget.m_position.rotation);
            explosion.transform.parent = ship.transform;
            explosion.GetComponent<AudioSource>().Play();
            Destroy(shipTarget.m_targetGraphic);

        }
Ejemplo n.º 59
0
 public void RespawnShip(ShipController aShip)
 {
     if (PhotonNetwork.isMasterClient)
     {
         GetComponent<PhotonView>().RPC("RespawnShipRPC", PhotonTargets.AllBuffered, aShip.m_shipID);
     }
 }
Ejemplo n.º 60
0
 public void AddSpawnedShip(ShipController aShip)
 {
     m_spawnedShips.Add(aShip);
 }