Esempio n. 1
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
    // Use this for initialization
    private void Awake()
    {
        level        = 2;
        lastHit      = 0;
        bombActive   = false;
        bombCount    = 0;
        laserSeconds = 0;

        if (instance == null)//only one instance active: singleton
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);//don't destroy when loading another scene

        if (SceneManager.GetActiveScene().name == "2DScene")
        {
            level = 0;
        }

        if (SceneManager.GetActiveScene().name == "2dEndlos")
        {
            level = 3;
        }
    }
Esempio n. 3
0
    void Awake()
    {
        //Singleton
        if (_instance == null)
        {
            _instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        UserPlatform = Application.platform;

        ButtonControls_Keyboard = new Dictionary <ButtonControlNames, KeyCode>();
        ButtonControls_Keyboard[ButtonControlNames.Start]     = KeyCode.Escape;
        ButtonControls_Keyboard[ButtonControlNames.UseAction] = KeyCode.X;
        ButtonControls_Keyboard[ButtonControlNames.UseItem]   = KeyCode.Z;
        ButtonControls_Keyboard[ButtonControlNames.Interact]  = KeyCode.Space;
        //ButtonControls_Keyboard["LeftBumper"] = KeyCode.L;
        //ButtonControls_Keyboard["RightBumper"] = KeyCode.K;

        ButtonControls_Controller = new Dictionary <ButtonControlNames, KeyCode>();
        SetDefaultControllerValuesBasedOffOS(UserPlatform);
    }
Esempio n. 4
0
File: Gun.cs Progetto: Fideos/U3D
    private void Awake()
    {
        /*
         * if (damage != new int[2])
         * {
         *  damage = new int[2];
         *  damage[0] = 30;
         *  damage[1] = 50;
         * }
         */
        //Debug.Log(damage[0] + ", " + damage[1]);

        playerInTrigger = false;

        if (bulletsPerShot <= 0)
        {
            bulletsPerShot = 1;
        }
        if (name == null)
        {
            name = "Default";
        }
        this.transform.rotation = Quaternion.Euler(90, 0, 0);
        currentManager          = GameObject.FindGameObjectWithTag("Manager").GetComponent <MyGameManager>();
    }
Esempio n. 5
0
    public override void SetUpInStart()
    {
        base.SetUpInStart();
        ShowItemsUICanvas.gameObject.SetActive(false);
        myGameManager = FindObjectOfType <MyGameManager>();

        Tower[]  towers       = new Tower[AvailableTowers.Count];
        Sprite[] towersSprite = new Sprite[AvailableTowers.Count];

        for (int i = 0; i < AvailableTowers.Count; i++)
        {
            towers[i] = AvailableTowers[i].gameObject.GetComponent <Tower>();
            GoldCoin g1 = new GoldCoin(towers[i].GoldToBuy);
            GoldCoin g2 = new GoldCoin(towers[i].GoldToSell);

            towers[i].BuyPrice  = new Price(g1);
            towers[i].SellPrice = new Price(g2);

            towersSprite[i] = AvailableTowersSprite[i].GetComponent <SpriteRenderer>().sprite;
        }

        m_transform = this.transform;

        Factory.prototypes       = towers;
        Factory.prototypesSprite = towersSprite;
    }
Esempio n. 6
0
    void Awake()
    {
        //Check if instance already exists
        if (instance == null)
        {
            //if not, set instance to this
            instance = this;
        }

        //If instance already exists and it's not this:
        else if (instance != this)
        {
            //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
            Destroy(gameObject);
        }

        //Sets this to not be destroyed when reloading scene
        DontDestroyOnLoad(gameObject);

        //Assign enemies to a new List of Enemy objects.
        enemies = new List <Enemy>();

        //Get a component reference to the attached BoardManager script
        boardScript = GetComponent <BoardGenerate>();

        //Call the InitGame function to initialize the first level
        InitGame();
    }
Esempio n. 7
0
    // Update is called once per frame
    void Update()
    {
        //Highlight on distance

        float dtp = Vector3.Distance(MyGameManager.GetInstance().GetPlayerTransform().position, objectTransform.position);

        if (grabbedState.Equals(GrabbedState.GRABBED))
        {
            cubeOutline.OutlineColor = new Color(255, 0, 0);
            cubeOutline.OutlineMode  = Outline.Mode.OutlineVisible;
        }

        else
        if (dtp <= distanceToPlayer)
        {
            if (hoveredOn)
            {
                cubeOutline.OutlineColor = new Color(0, 255, 0);
            }
            else
            {
                cubeOutline.OutlineColor = new Color(255, 255, 255);
            }

            cubeOutline.OutlineMode = Outline.Mode.OutlineVisible;
        }
        else if (dtp > distanceToPlayer)
        {
            cubeOutline.OutlineMode = Outline.Mode.SilhouetteOnly;
        }
    }
Esempio n. 8
0
 void Start()
 {
     mgm = GameObject.Find("GameManager").GetComponent <MyGameManager> ();
     //ScoreBoardtoGo = GameObject.Find ("DogScore").transform.localPosition;
     targetGen = GameObject.Find("TargetGen").GetComponent <TargetGen> ();
     FloatingTextController.Initialize();
 }
Esempio n. 9
0
 private void Start()
 {
     starTrans = GetComponent <Transform>();
     if (myGameManager == null)
     {
         myGameManager = FindObjectOfType <MyGameManager>();
     }
 }
Esempio n. 10
0
 void Alive()
 {
     transform.position = iniPos;
     MyGameManager.getInstance().vacio = false;
     MyGameManager.getInstance().Loselife();
     muerto = false;
     //Invoke("Vivo", 0.05f);
 }
 public override void OnEnable()
 {
     base.OnEnable();
     if (instance == null)
     {
         instance = this;
     }
 }
Esempio n. 12
0
 void OnTriggerEnter(Collider collider)
 {
     if (collider.gameObject.tag == "Player")
     {
         MyGameManager.GetInstance().GetComponent <ScoreComponent>().StopScoring(false);
         LoadScoreboard();
     }
 }
 void Start()
 {
     gameManager                  = FindObjectOfType <MyGameManager>();
     markersPool                  = FindObjectOfType <MarkersPool>();
     replayController             = FindObjectOfType <ReplayController>();
     playerMovement               = FindObjectOfType <PlayerMovement>();
     playerMovement.OnPlayerJump += OnJump;
 }
Esempio n. 14
0
 // Start is called before the first frame update
 void Start()
 {
     MyGameManager.GetInstance().SetGameState(GameState.LEVEL);
     Debug.Log(MyGameManager.GetInstance().GetGameState());
     MyGameManager.GetInstance().SpawnPlayer();
     levelUI = GameObject.Find("InGameUI");
     MyGameManager.GetInstance().GetComponent <ScoreComponent>().StopScoring(false);
 }
Esempio n. 15
0
    public override void Awake()
    {
        base.Awake();

        isClear    = false;
        curMapData = MyGameManager.Get().selectedMapData;
        ShowMapData(curMapData);
    }
Esempio n. 16
0
 public static MyGameManager Get()
 {
     if (_instance == null)
     {
         _instance = new MyGameManager();
     }
     return(_instance);
 }
Esempio n. 17
0
	void FixedUpdate()
	{
		GameManager.GameState gameState = MyGameManager.GetComponent<GameManager>().CurrentGameState;
		if (gameState != GameManager.GameState.AIMING && gameState != GameManager.GameState.THROWING)
		{
			Velocity.Scale(new Vector3(0.98f, 0.98f));
			transform.position += Velocity / 60;
		}
	}
Esempio n. 18
0
 // Start is called before the first frame update
 void Start()
 {
     if (myGameManager == null)
     {
         myGameManager = FindObjectOfType <MyGameManager>();
     }
     FindRoadPath();
     StartCoroutine(FollowPath());
 }
Esempio n. 19
0
    void OnTriggerEnter(Collider hit)
    {
        Controller2 player = hit.GetComponent <Controller2> ();

        if (player != null)
        {
            MyGameManager.TogglePromptText(true);
            MyGameManager.ToggleNarrationText(true);
        }
    }
Esempio n. 20
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
Esempio n. 21
0
 void Alive2()
 {
     if (MyGameManager.getInstance().hits <= 1)
     {
         transform.position = iniPos;
         MyGameManager.getInstance().gelatina.color = Color.green;
     }
     MyGameManager.getInstance().Loselife();
     muerto = false;
     //Invoke("Vivo", 0.05f);
 }
Esempio n. 22
0
    public void OnEndDrag(PointerEventData eventData)
    {
        itemBeingDragged = null;
        MyGameManager.Get().AddVertexMovedCount();

        //if (_rectTrans.position.y > parentCanvas.pixelRect.yMin && _rectTrans.position.y < parentCanvas.pixelRect.yMax
        //    && _rectTrans.position.x > parentCanvas.pixelRect.xMin && _rectTrans.position.x < parentCanvas.pixelRect.xMax)
        //    return;
        //else
        //    _rectTrans.position = startPosition;
    }
Esempio n. 23
0
 //Irrelevant for the Line of sight algorithm
 void Awake()
 {
     if (MyGameManager.itself != null)
     {
         Destroy(itself.gameObject);
         itself = this;
     }
     else
     {
         itself = this;
     }
 }
Esempio n. 24
0
 void MakeSingleton()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Esempio n. 25
0
 private void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
 }
Esempio n. 26
0
    // Start is called before the first frame update
    void Start()
    {
        gameManager = MyGameManager.GetInstance();

        m_Dropdown = GetComponent <Dropdown>();

        m_Dropdown.onValueChanged.AddListener(delegate {
            DropdownValueChanged(m_Dropdown);
        });

        gameManager.SetEnemyColor(m_Dropdown.value);
    }
Esempio n. 27
0
	// Update is called once per frame
	protected override void LateUpdate()
	{
		GameManager.GameState gameState = MyGameManager.GetComponent<GameManager>().CurrentGameState;
		// I hate C#
		// I know I'm doing this wrong
		// But I still hate C#
		if (gameState == GameManager.GameState.AIMING || gameState == GameManager.GameState.THROWING)
		{
			rockOffset = new Vector3(-0.7f, -0.05f);
			base.LateUpdate();
		}
	}
Esempio n. 28
0
 // Update is called once per frame
 void Update()
 {
     if (paused)
     {
         return;
     }
     GameManager.GameState gameState = MyGameManager.GetComponent <GameManager>().CurrentGameState;
     if (gameState == GameManager.GameState.SWEEPING)
     {
         float   maxSweepOffset = 0.4f;
         Vector3 offsetDelta    = new Vector3(0f, 0.03f);
         if (Utils.GetKey_Up() && SweepOffset.y < maxSweepOffset)
         {
             SweepOffset += offsetDelta;
         }
         if (Utils.GetKey_Down() && SweepOffset.y > -maxSweepOffset)
         {
             SweepOffset -= offsetDelta;
         }
         if (Utils.GetKey_Confirm() || broomAnimate > 0)
         {
             if (broomAnimate == 0f)
             {
                 if (Utils.GetKeyDown_Confirm())
                 {
                     singleSweepSource.Play();
                 }
                 else
                 {
                     multiSweepSource.Play();
                 }
             }
             broomAnimate += 0.6f;
         }
         if (broomAnimate >= 2 * Mathf.PI)
         {
             broomAnimate = 0;
         }
         Broom.transform.localPosition = baseBroomOffset + new Vector3(0f, Mathf.Sin(broomAnimate) * 0.15f);
     }
     else if (gameState == GameManager.GameState.WATCHING)
     {
         if (Broom.GetComponent <SpriteRenderer>().color.a > 0)
         {
             Broom.GetComponent <SpriteRenderer>().color -= new Color(0, 0, 0, 0.05f);
         }
         else if (GetComponent <SpriteRenderer>().color.a > 0)
         {
             GetComponent <SpriteRenderer>().color -= new Color(0, 0, 0, 0.05f);
         }
     }
 }
Esempio n. 29
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        MyGameManager mgm = GameObject.Find("GameManager").GetComponent <MyGameManager>();

        if (collider.gameObject.tag == "TargetCoin" || collider.gameObject.tag == "TargetSkull")
        {
            //Vector2 targetpos = collider.gameObject.transform.position;

            collider.gameObject.GetComponent <Rigidbody2D> ().AddForce(new Vector2(base.pullPower, 0f));

            if (base.pullPower > 0.0f)
            { // dog side
                if (collider.gameObject.tag == "TargetCoin")
                {
                    // dog action correct
                    mgm.dogReward = 0.01f;
                }
                else
                {
                    // dog action incorrect
                    mgm.dogReward = -0.01f;
                }
            }
            else
            { // cat side
                if (collider.gameObject.tag == "TargetCoin")
                {
                    // cat action correct
                    mgm.catReward = 0.01f;
                }
                else
                {
                    // cat action incorrect
                    mgm.catReward = -0.01f;
                }
            }
        }
        else
        {   /*
             * if (base.pullPower > 0.0f)
             * {
             *  mgm.dogReward = -0.1f;
             * }
             * else
             * {
             *  mgm.catReward = -0.1f;
             * }
             */
        }
        //Destroy (gameObject);
        base.OnTriggerEnter2D(collider);
    }
Esempio n. 30
0
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);
        }

        else if (Instance != this)
        {
            Destroy(gameObject);
        }
    }
Esempio n. 31
0
 public void Awake()
 {
     _instance = this;
 }
Esempio n. 32
0
    public void Initialize(MyGameManager _game, MyGameRoom _prevRoom = null, bool _finalRoom = false)
    {
        gameManager = _game;
            prevRoom = _prevRoom;
            roomPos = transform.position;
            baseRoom = transform;
            trigger = baseRoom.gameObject.AddComponent<RoomEntranceTrigger> ();
            //previous room cleanup
            roomInitialized = false;

            // Texture tex = gameManager.floorTexs[UnityEngine.Random.Range (0, gameManager.floorTexs.Length)];
            for (int i = 0; i < groundRenderers.Length; i++) {
                groundRenderers[i].material.SetTexture ("_MainTex", MyGameManager.state.wallTex);
            }

            bool roofless = (MyGameManager.state.roomTypeData.ceilingType == RoomCeilingType.None || MyGameManager.state.roomTypeData.ceilingType == RoomCeilingType.Open);
            //generate floor
            if (MyGameManager.state.roomTypeData.floorType == RoomFloorType.Dome) {
                AttachObject (gameManager.floorDomePool.SpawnFromPool ());
            } else if (MyGameManager.state.roomTypeData.floorType == RoomFloorType.Spike) {
                AttachObject (gameManager.floorSpikePool.SpawnFromPool ());
            }

            //calculate doors - generate walkway and attached game rooms for each door
            int doorCountAdj = (prevRoom != null) ? 1 : 0;
            int doorCount = (_finalRoom) ?  doorCountAdj : 1 + doorCountAdj;

            if (!roofless) {
                if (MyGameManager.state.roomTypeData.ceilingType == RoomCeilingType.Spike) {
                    AttachObject (gameManager.ceilingSpikePool.SpawnFromPool (), true);
                } else if (MyGameManager.state.roomTypeData.ceilingType == RoomCeilingType.Dome) {
                    AttachObject (gameManager.ceilingDomePool.SpawnFromPool (), true);
                } else {
                    AttachObject (gameManager.ceilingClosedPool.SpawnFromPool (), true);
                }

                for (int i = 0; i < doorCount; i++) {
                    doors.Add (_game.doorPool.SpawnFromPool (roomPos));
                }

                //generate walls
                int wallCount = 5 - doorCount;
                for (int i = 0; i < wallCount; i++) {
                    walls.Add (_game.wallPool.SpawnFromPool (roomPos));
                }
            }
            //set wall and door orientations
            int wallIndex = 0;
            int doorIndex = 0;
            int rotation = 0;
            int targ = UnityEngine.Random.Range (2,4);

            for (int i = 0; i < 5; i++) {
                if (doorIndex < doorCount && (i == 0 || i == targ)) {	//theres a door available and its an appropriate slot
                    if (!_finalRoom && (i != 0 || prevRoom == null)) {
                        nextRoomIndex.Add (i);
                    }
                    if (!roofless) {
                        doors[doorIndex].parent = attachmentAnchor;
                        doors[doorIndex].eulerAngles = new Vector3 (0, doors[doorIndex].parent.eulerAngles.y + rotation, 0);
                        Renderer[] rend = doors[doorIndex].GetComponentsInChildren<Renderer> ();
                        // if (rend != null) {
                        for (int j = 0; j < rend.Length; j++) {
                            rend[j].material.SetTexture ("_MainTex", MyGameManager.state.wallTex);
                        }
                    }
                    doorIndex++;
                } else {
                    if (!roofless) {
                        walls[wallIndex].parent = attachmentAnchor;
                        walls[wallIndex].eulerAngles = new Vector3 (0, walls[wallIndex].parent.eulerAngles.y + rotation, 0);
                        Renderer[] rend = walls[wallIndex].GetComponentsInChildren<Renderer> ();
                        // if (rend != null) {
                        for (int j = 0; j < rend.Length; j++) {
                            rend[j].material.SetTexture ("_MainTex", MyGameManager.state.wallTex);
                        }
                    }
                    wallIndex++;
                }
                rotation += wallAngle;
            }
            if (prevRoom == null) {
                // Transform decal = gameManager.decalPool[UnityEngine.Random.Range (0, gameManager.decalPool.Count)].SpawnFromPool();
                // decal.parent = attachmentAnchor;
                // decal.localPosition = new Vector3 (0, 2, 0);
                // AttachObject (gameManager.lightPool.SpawnFromPool());
                AttachObject (gameManager.narrativePool.SpawnFromPool());

            } else if (_finalRoom) {
                // Transform decal = gameManager.decalPool[UnityEngine.Random.Range (0, gameManager.decalPool.Count)].SpawnFromPool();
                AttachObject (gameManager.portalPool.SpawnFromPool());
                // decal.parent = attachmentAnchor;
                // decal.localPosition = new Vector3 (0, 2, 0);

            } else {
                if (roofless) {
                    AttachObject (gameManager.torchPool.SpawnFromPool());
                    // Transform decal = gameManager.decalPool[UnityEngine.Random.Range (0, gameManager.decalPool.Count)].SpawnFromPool();
                    // decal.parent = attachmentAnchor;
                    // decal.localPosition = new Vector3 (0, 2, 0);
                } else {
                    AttachObject (gameManager.lightPool.SpawnFromPool());
                }

                int roomType = UnityEngine.Random.Range (0, 5);
                if (roomType >= 4) {

                } else if (roomType >= 3) {

                }
            }
            if (roofless) {
                for (int j = 0; j < columnRenderers.Length; j++) {
                    columnRenderers[j].gameObject.SetActive (false);
                }
            } else {
            //Column Customization
                for (int j = 0; j < columnRenderers.Length; j++) {
                    columnRenderers[j].gameObject.SetActive (true);
                    columnRenderers[j].material = MyGameManager.state.columnMat;
                }
            }

            // transform.name += gameManager.rooms.Count;

            if (prevRoom != null) {
                transform.transform.LookAt (prevRoom.transform, Vector3.up);

                Vector3 offset = new Vector3 (0, -18, 0);
                transform.eulerAngles = transform.transform.eulerAngles + offset;
            }
            InitializeConnections ();
    }