Inheritance: MonoBehaviour
Exemplo n.º 1
0
    void Throw()
    {
        _holding = false;
        _anim.SetTrigger("ToggleHold");
        _anim.SetLayerWeight(1, 0f);
        _heldItem.parent = GameObject.Find("Game").transform;
        // Add forces
        Rigidbody r = _heldItem.GetComponent <Rigidbody>();

        r.isKinematic = false;
        r.velocity    = transform.GetComponent <Rigidbody>().velocity;
        r.AddForce((transform.forward * 600f * Mathf.Clamp(_fVelocity, 0.05f, 1f) * (_airborn ? 2f : 3.5f)) + new Vector3(0f, (_airborn ? 3f : 1.5f), 0f) * 220f);
        r.AddTorque(new Vector3(transform.forward.z, 0f, -transform.forward.x) * 100f);
        _heldItem.gameObject.layer = 0;
        // Fire script
        PlayerCube script = _heldItem.GetComponent <PlayerCube>();

        if (script != null)
        {
            script.OnThrow();
        }
        // Remove held item
        _heldItem   = null;
        _throwTimer = Time.time;
    }
Exemplo n.º 2
0
 public void Start()
 {
     currentLevel = Levels.levelSelector;
     ArrayCopy();
     GenerateBoard();
     playerCube = FindObjectOfType <PlayerCube>();
 }
Exemplo n.º 3
0
    public void Start()
    {
        if (PhotonNetwork.IsMasterClient != true)
        {
            return;
        }
        if (FindObjectOfType <PlayerCube>() != null)
        {
            map     = FindObjectOfType <GameMapGenerator>();
            player  = FindObjectOfType <PlayerCube>();
            playerT = player.transform;

            //enemyp = enemy.gameObject;
            //greenEnemyp = greenEnemy.gameObject;
            //yellowEnemyp = yellowEnemy.gameObject;
            //orangeEnemyp = orangeEnemy.gameObject;
            //blackEnemyp = blackEnemy.gameObject;

            //if (gameStarted == false)
            //{
            photonView.RPC("NextWave", RpcTarget.AllBuffered, "STARTING ENEMY WAVES!");
            //    gameStarted = true;
            //}
        }
    }
Exemplo n.º 4
0
 void Awake()
 {
     character_manager    = FindObjectOfType <CharacterManager>();
     player               = FindObjectOfType <PlayerCube>();
     score_display        = FindObjectOfType <ScoreDisplay>();
     incorrect_characters = new List <String>();
 }
Exemplo n.º 5
0
    public void FixedUpdate()
    {
        if (SpeedUpgrades.Count > 0)
        {
            CurrentSpeedUpgrade   = SpeedUpgrades[0];
            SpeedUpgradeText.text = "Speed, Cost: " + CurrentSpeedUpgrade.Cost.ToString();
        }
        else
        {
            SpeedUpgradeText.text = "Speed Fully Upgraded!";
        }

        if (ArmorUpgrades.Count > 0)
        {
            CurrentArmorUpgrade   = ArmorUpgrades[0];
            ArmorUpgradeText.text = "Armor, Cost: " + CurrentArmorUpgrade.Cost.ToString();
        }
        else
        {
            ArmorUpgradeText.text = "Armor Fully Upgraded!";
        }

        if (cubeToUpgrade == null)
        {
            cubeToUpgrade = GameObject.FindObjectOfType <PlayerCube>();
        }
    }
Exemplo n.º 6
0
    public void FixedUpdate()
    {
        if (PhotonNetwork.IsMasterClient != true)
        {
            return;
        }
        if (foundPlayer == false)
        {
            var plr = FindObjectOfType <PlayerCube>();
            if (plr != null)
            {
                map     = FindObjectOfType <GameMapGenerator>();
                player  = FindObjectOfType <PlayerCube>();
                playerT = player.transform;

                photonView.RPC("NextWave", RpcTarget.AllBuffered, "STARTING ENEMY WAVES!");
                foundPlayer = true;
            }
        }
        if (remainingEnemiesToSpawn > 0 && Time.time > nextSpawnTime)
        {
            remainingEnemiesToSpawn--;
            nextSpawnTime = Time.time + currentWave.timeBetweenSpawns;

            if (enemyObjects.Count > 0)
            {
                GameObject enemyToSpawn     = enemyObjects.First();
                int        enemyObjectIndex = enemyObjects.IndexOf(enemyToSpawn);
                StartCoroutine(SpawnEnemy(enemyToSpawn));
                enemyObjects.RemoveAt(enemyObjectIndex);
            }
        }
    }
Exemplo n.º 7
0
    private void Awake()
    {
        if (photonView.IsMine != true)
        {
            return;
        }

        foreach (Transform t in this.transform.Find("Model"))
        {
            if (t.name == "Firing")
            {
                Weapons.Add(t);
            }
        }

        Cube   = this.GetComponent <PlayerCube>();
        Weapon = Cube.weapon;
        foreach (FiringPoint Point in Weapon.Points)
        {
            NextTimesToFire.Add(0);
        }
        foreach (FiringPoint Point in Weapon.Points)
        {
            SplitFiringSelection.Add(0);
        }
    }
Exemplo n.º 8
0
    [PunRPC] public void EndGame(int[] ids)
    {
        List <float>      scores  = new List <float>();
        List <GameObject> players = new List <GameObject>();

        foreach (int id in ids)
        {
            GameObject obj = PhotonView.Find(id).gameObject;
            players.Add(obj);
            PlayerCube p = obj.GetComponent <PlayerCube>();
            scores.Add(p.score);
        }

        var max = Mathf.Max(scores.ToArray());

        foreach (GameObject p in players)
        {
            if (p.GetComponent <PlayerCube>().score == max)
            {
                ControlText.text = "The Winner Is: " + p.transform.name;
            }
        }

        StartCoroutine(FinishGame());
    }
    private void Update()
    {
        // In case the object was disabled while dragging around;
        // (Undo action 'deleted' the object while the cube was being dragged around)
        if (currentlySelectedCube != null)
        {
            if (!currentlySelectedCube.gameObject.activeInHierarchy)
            {
                currentlySelectedCube.DeselectCube();
                currentlySelectedCube = null;
            }
        }


        if (Input.GetKeyDown(DRAG_KEY))
        {
            // Cant select another cube if one is currently selected.
            if (currentlySelectedCube == null)
            {
                HandlePlayerSelectingCube();
            }
        }

        if (Input.GetKeyUp(DRAG_KEY) && currentlySelectedCube != null)
        {
            MoveAction moveAction = new MoveAction(currentlySelectedCube.gameObject, startDragPosition, currentlySelectedCube.transform.position);
            UserActionCache.Instance.AddActionPerformed(moveAction);

            currentlySelectedCube.DeselectCube();
            currentlySelectedCube = null;
        }

        if (currentlySelectedCube != null)
        {
            MoveCurrentlySelectedCubeByCursorMovement();

            if (Input.GetKeyDown(DELETE_KEY))
            {
                DeleteAction deleteAction = new DeleteAction(currentlySelectedCube.gameObject);
                UserActionCache.Instance.AddActionPerformed(deleteAction);

                currentlySelectedCube.DeselectCube();
                currentlySelectedCube.gameObject.SetActive(false);
                currentlySelectedCube = null;
            }
        }


        if (Input.GetKeyDown(UNDO_KEY))
        {
            UserActionCache.Instance.UndoLastAction();
        }

        if (Input.GetKeyDown(REDO_KEY))
        {
            UserActionCache.Instance.RedoLastUndoneAction();
        }
    }
Exemplo n.º 10
0
    private void Awake()
    {
        player = FindObjectOfType <PlayerCube>();

        for (int i = 1; i <= 4; i++)
        {
            List <Cube> stagei = new List <Cube>();
            stagelist.Add(stagei);
        }
    }
Exemplo n.º 11
0
 public void Init(Vector3Int sectionOffset, SectionData sectionData, PlayerCube playerCube)
 {
     _grid           = GridManager.Instance.Grid;
     _sectionOffset  = sectionOffset;
     _sectionData    = sectionData;
     _playerCube     = playerCube;
     _cubesByCellPos = new Dictionary <Vector3Int, Cube>();
     CreateCubes();
     _shapeDetector = new SectionShapeDetector(_grid, this, _cubesByCellPos);
 }
Exemplo n.º 12
0
    private void Createplayer()
    {
        Vector3 pos = Selection.activeGameObject.transform.position;

        pos.y += scalex;
        PlayerCube cube = Instantiate(playerCube, pos, Quaternion.identity);

        cube.highlightColor = highlightColor;
        cube.cubecolor      = playerColor;
    }
Exemplo n.º 13
0
 void Awake()
 {
     sprite_renderer      = GetComponent <SpriteRenderer>();
     gos                  = FindObjectOfType <GameObjects>();
     player               = FindObjectOfType <PlayerCube>();
     behaviour            = ShooterEnemyBehaviour.MovingSilently;
     movement             = GetComponent <Movement>();
     my_rand              = new Random();
     start_shoot_interval = shoot_interval;
 }
Exemplo n.º 14
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(this);
     }
     if (explosionPoint == null)
     {
         explosionPoint = transform;
     }
 }
Exemplo n.º 15
0
    private void OnGUI()
    {
        gridPrefab   = EditorGUILayout.ObjectField("Grid Prefab:", gridPrefab, typeof(Cube), true) as Cube;
        cubePrefab   = EditorGUILayout.ObjectField("Cube Prefab:", cubePrefab, typeof(GameObject), true) as GameObject;
        moveAblePref = EditorGUILayout.ObjectField("Mova Able Prefab", moveAblePref, typeof(MoveAbleBlock), true) as MoveAbleBlock;
        constBlock   = EditorGUILayout.ObjectField("Const Block", constBlock, typeof(GameObject), true) as GameObject;
        playerCube   = EditorGUILayout.ObjectField("Player Prefab", playerCube, typeof(PlayerCube), true) as PlayerCube;

        playerColor    = EditorGUILayout.ColorField("Player Color", playerColor);
        blockColor     = EditorGUILayout.ColorField("Block Color", blockColor);
        highlightColor = EditorGUILayout.ColorField("Highlight color", highlightColor);
        moveAmount     = EditorGUILayout.IntField("Move amount: ", moveAmount);
        row            = EditorGUILayout.IntField("Row: ", row);
        column         = EditorGUILayout.IntField("Column: ", column);
        stageNum       = EditorGUILayout.IntField("Stage Number: ", stageNum);
        if (GUILayout.Button("Generate"))
        {
            GenerateLevel();
        }
        if (GUILayout.Button("Change To grid"))
        {
            ChangetoGrid();
        }
        if (GUILayout.Button("Change To Wall"))
        {
            ChangeToWall();
        }
        if (GUILayout.Button("ADD Block"))
        {
            ChangeToBlock();
        }
        if (GUILayout.Button("Const Block"))
        {
            CreateConstBlock();
        }
        if (GUILayout.Button("Create Player"))
        {
            Createplayer();
        }
    }
    private void HandlePlayerSelectingCube()
    {
        if (PlayerNotClickingOnInterface())
        {
            if (TryGetClickedCube(out PlayerCube selectedCube))
            {
                selectedCube.SelectCube();
                currentlySelectedCube = selectedCube;

                startDragPosition = selectedCube.transform.position;
            }
        }

        #region Local_Function

        bool TryGetClickedCube(out PlayerCube playerCube)
        {
            var ray = mainCamera.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out RaycastHit hit))
            {
                if (hit.transform.CompareTag(cubeTag))
                {
                    playerCube = hit.transform.GetComponent <PlayerCube>();
                    return(true);
                }
            }

            playerCube = null;
            return(false);
        }

        bool PlayerNotClickingOnInterface()
        {
            return(!currentEventSystem.IsPointerOverGameObject());
        }

        #endregion
    }
Exemplo n.º 17
0
    bool Hold(GameObject holdObject)
    {
        PlayerCube script = holdObject.GetComponent <PlayerCube>();

        if (script != null && !_holding && !_diving && Time.time - _throwTimer > 0.2f)
        {
            if (!script.OnHold())
            {
                return(false);
            }
            _holding = true;
            _anim.SetTrigger("ToggleHold");
            _anim.SetLayerWeight(1, 1f);
            _heldItem               = holdObject.transform;
            _heldItem.rotation      = Quaternion.identity;
            _heldItem.parent        = _anim.transform;
            _heldItem.localPosition = new Vector3(0f, 1.971f + script.GetSize() / 2f, 0f);
            _heldItem.GetComponent <Rigidbody>().isKinematic = true;
            _heldItem.gameObject.layer = 2;
            return(true);
        }
        return(false);
    }
 private void Awake()
 {
     currentEventSystem    = EventSystem.current;
     mainCamera            = Camera.main;
     currentlySelectedCube = null;
 }
Exemplo n.º 19
0
 private void Awake()  //PUT RANDOM ENEMY POWER
 {
     player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerCube>();
     power  = Random.Range(PlayerCube.score / 2, PlayerCube.score * 2);
 }
Exemplo n.º 20
0
        public Section CreateSection(Vector3Int sectionOffset, SectionData sectionData, PlayerCube playerCube, Transform parent = null)
        {
            Section section = GameObject.Instantiate(ResourceManager.Instance.GetResource <GameObject>("Section"), parent).GetComponent <Section>();

            section.Init(sectionOffset, sectionData, playerCube);
            return(section);
        }
Exemplo n.º 21
0
 private void Awake()
 {
     instance      = this;
     cubeToUpgrade = GameObject.FindObjectOfType <PlayerCube>();
 }
Exemplo n.º 22
0
 private void Start()
 {
     playerCube = GetComponent <PlayerCube>();
 }
Exemplo n.º 23
0
 private void Start()
 {
     rend       = GetComponent <Renderer>();
     startColor = rend.material.color;
     playerCube = FindObjectOfType <PlayerCube>();
 }
Exemplo n.º 24
0
        public PlayerCube CreatePlayerCube(Transform parent = null)
        {
            PlayerCube playerCube = GameObject.Instantiate(ResourceManager.Instance.GetResource <GameObject>("PlayerCube"), parent).GetComponent <PlayerCube>();

            return(playerCube);
        }
Exemplo n.º 25
0
 void Awake()
 {
     player = FindObjectOfType <PlayerCube>();
 }