예제 #1
0
 void Start()
 {
     id         = GetComponent <PlayerIdentity>();
     movement   = GetComponent <PlayerMovement3D>();
     ui         = GetComponentInChildren <InWorldUI>();
     sfxManager = GetComponentInChildren <NetworkedSFXManager>();
 }
예제 #2
0
    void OnGUI() {
		Scene scene = SceneManager.GetActiveScene();
		if (scene.name == "hunterVictory" || scene.name == "seekerVictory" ) {
			return;
		}

        // Player manager doesn't have the players on start
        if (!id) {
            if (PlayerManager.instance.thisPlayer) {
				thisPlayer = PlayerManager.instance.thisPlayer;
                id = thisPlayer.GetComponent<PlayerIdentity>();
				movement = thisPlayer.GetComponent<PlayerMovement3D>();
            }
        }

//		if (id && id.IsSeeker()) {
//			DrawSeekerUI();
//		}

        if (id && id.IsHunter()) {
			DrawHunterUI();
        }

		// DrawMinimap();
    }
예제 #3
0
    public void SetPreparations()
    {
        data.actualScene = (SceneEnum)System.Enum.Parse(typeof(SceneEnum), SceneManager.GetActiveScene().name);

        if (data.actualScene != SceneEnum.StoryboardN1 && data.actualScene != SceneEnum.StoryboardN2 && data.actualScene != SceneEnum.StoryboardN3 && data.actualScene != SceneEnum.StoryboardN4)
        {
            GameObject player = GameObject.FindGameObjectWithTag("Player");

            data.moneyCount  = player.GetComponent <MoneyHolder>().ActualMoney;
            data.waveName    = GameObject.FindGameObjectWithTag("WaveSpawner").GetComponent <WaveSpawner>().GetActualWaveName();
            data.enemyBodies = BodiesHolder.Instance.GetBodies();

            PlayerMovement3D pMovScript = player.GetComponent <PlayerMovement3D>();

            for (int i = 0; i < (int)Buyable.COUNT; i++)
            {
                data.playerUpgrades[i] = pMovScript.GetUpgradeValue(i);
            }
        }
        else
        {
            data.waveName    = "wave 1";
            data.enemyBodies = 0;
        }

        data.saveCreated = true;
    }
예제 #4
0
    void OnGUI()
    {
        Scene scene = SceneManager.GetActiveScene();

        if (scene.name == "hunterVictory" || scene.name == "seekerVictory")
        {
            return;
        }

        // Player manager doesn't have the players on start
        if (!id)
        {
            if (PlayerManager.instance.thisPlayer)
            {
                thisPlayer = PlayerManager.instance.thisPlayer;
                id         = thisPlayer.GetComponent <PlayerIdentity>();
                movement   = thisPlayer.GetComponent <PlayerMovement3D>();
            }
        }

//		if (id && id.IsSeeker()) {
//			DrawSeekerUI();
//		}

        if (id && id.IsHunter())
        {
            DrawHunterUI();
        }

        // DrawMinimap();
    }
예제 #5
0
    public override void OnTriggerExit(Collider thisPlayer)
    {
        base.OnTriggerExit(thisPlayer);
        // Leave grass when the player walks outside
        HidingManager    hidingManager = thisPlayer.gameObject.GetComponent <HidingManager>();
        PlayerMovement3D movement      = thisPlayer.gameObject.GetComponent <PlayerMovement3D>();

        hidingManager.CmdStopHiding();

        movement.inGrass = false;
        movement.onGrass = false;
    }
예제 #6
0
        private void checkInputMode()
        {
            switch (inputMode)
            {
            case INPUT_MODE.GAMEPAD:
                mouseInput.activeInput = false;
                playerMovement         = GetComponent <PlayerMovement3D_GPad>();
                break;

            case INPUT_MODE.POINTNCLICK:
                mouseInput.activeInput = true;
                playerMovement         = GetComponent <PlayerMovement3D_PNC>();
                break;
            }
        }
예제 #7
0
    void Start()
    {
        _player = GetComponent <PlayerMovement3D>();
        //Speed related
        speed       = 3f;
        normalSpeed = speed;
        aggroSpeed  = 8f;
        countdown   = timer;

        //Stamina related

        SightRange = 4f;


        currentWP         = Random.Range(0, WayPoints.Length);
        targetOldPosition = target.position;
        myState           = State.Search;
    }
예제 #8
0
    public override void SeekerInteraction(Collider thisPlayer)
    {
        HidingManager    hidingManager = thisPlayer.gameObject.GetComponent <HidingManager>();
        PlayerMovement3D movement      = thisPlayer.gameObject.GetComponent <PlayerMovement3D>();

        if (!hidingManager.IsHiding())
        {
            hidingManager.CmdHideInArea();
            movement.onGrass = false;
            movement.inGrass = true;
        }
        else
        {
            hidingManager.CmdStopHiding();
            movement.onGrass = true;
            movement.inGrass = false;
        }
    }
    void Update()
    {
        GameObject hunter = PlayerManager.instance.hunter;
        GameObject seeker = PlayerManager.instance.seeker;

        if (!seeker || !hunter)
        {
            return;
        }

        PlayerMovement3D hunterMovement = hunter.GetComponent <PlayerMovement3D>();
        PlayerMovement3D seekerMovement = seeker.GetComponent <PlayerMovement3D>();

        AudioSource hunterAudio = hunter.GetComponent <AudioSource>();
        AudioSource seekerAudio = seeker.GetComponent <AudioSource>();

        if (CheckState(seekerMovement.inWater, seekerAudio, splashing))
        {
            return;
        }
        if (CheckState(hunterMovement.inWater, hunterAudio, splashing))
        {
            return;
        }

        if (CheckState(seekerMovement.onGrass, seekerAudio, onGrass))
        {
            return;
        }
        if (CheckState(seekerMovement.inGrass, seekerAudio, inGrass))
        {
            return;
        }

        if (CheckState(seekerMovement.sprinting, seekerAudio, walkingQuickly))
        {
            return;
        }
        if (CheckState(seekerMovement.isMoving, seekerAudio, walkingSlowly))
        {
            return;
        }
    }
예제 #10
0
	void Start () {
		id = GetComponent<PlayerIdentity>();
		movement = GetComponent<PlayerMovement3D>();
		ui = GetComponentInChildren<InWorldUI>();
		sfxManager = GetComponentInChildren<NetworkedSFXManager>();
	}
예제 #11
0
 void Awake()
 {
     instance = this;
 }
예제 #12
0
    public void OnEndDrag(PointerEventData eventData)
    {
        if (EventSystem.current.IsPointerOverGameObject())
        {
            Vector2 finalPos = GetComponent <RectTransform>().anchoredPosition; //position that the item was dropped on canvas

            Vector2 finalSlot;
            finalSlot.x = Mathf.Floor(finalPos.x / slotSize.x);  //which x slot it is
            finalSlot.y = Mathf.Floor(-finalPos.y / slotSize.y); //which y slot it is

            // test if item is inside slot area
            if (((int)(finalSlot.x) + (int)(item.itemSize.x) - 1) < invMan.maxGridX &&
                ((int)(finalSlot.y) + (int)(item.itemSize.y) - 1) < invMan.maxGridY &&
                ((int)(finalSlot.x)) >= 0 && (int)finalSlot.y >= 0)
            {
                List <Vector2> newPosItem = new List <Vector2>(); //new item position in bag
                bool           fit        = false;


                for (int sizeY = 0; sizeY < item.itemSize.y; sizeY++)
                {
                    for (int sizeX = 0; sizeX < item.itemSize.x; sizeX++)
                    {
                        if (invMan.grid[(int)finalSlot.x + sizeX, (int)finalSlot.y + sizeY] != 1)
                        {
                            Vector2 pos;
                            pos.x = (int)finalSlot.x + sizeX;
                            pos.y = (int)finalSlot.y + sizeY;
                            newPosItem.Add(pos);
                            fit = true;
                        }
                        else
                        {
                            fit = false;

                            this.transform.GetComponent <RectTransform>().anchoredPosition = oldPosition; //back to old pos
                            sizeX = (int)item.itemSize.x;
                            sizeY = (int)item.itemSize.y;
                            newPosItem.Clear();
                        }
                    }
                }
                if (fit)
                {                                                                                //delete old item position in bag
                    for (int i = 0; i < item.itemSize.y; i++)                                    //through item Y
                    {
                        for (int j = 0; j < item.itemSize.x; j++)                                //through item X
                        {
                            invMan.grid[(int)startPosition.x + j, (int)startPosition.y + i] = 0; //clean old pos
                        }
                    }

                    for (int i = 0; i < newPosItem.Count; i++)
                    {
                        invMan.grid[(int)newPosItem[i].x, (int)newPosItem[i].y] = 1; // add new pos
                    }

                    this.startPosition = newPosItem[0]; // set new start position
                    transform.GetComponent <RectTransform>().anchoredPosition = new Vector2(newPosItem[0].x * slotSize.x, -newPosItem[0].y * slotSize.y);
                }
                else //It'll snap back to its OG pos
                {
                    for (int i = 0; i < item.itemSize.y; i++) //through item Y
                    {
                        for (int j = 0; j < item.itemSize.x; j++)                                //through item X
                        {
                            invMan.grid[(int)startPosition.x + j, (int)startPosition.y + i] = 1; //back to position 1;
                        }
                    }
                }
            }
            else
            { // out of index, back to the old pos
                this.transform.GetComponent <RectTransform>().anchoredPosition = oldPosition;
            }
        }
        else
        {
            PlayerMovement3D player = FindObjectOfType <PlayerMovement3D>();


            Instantiate(item.thisItemsPrefab, new Vector2(player.transform.position.x + Random.Range(-1.5f, 1.5f),
                                                          player.transform.position.y + Random.Range(-1.5f, 1.5f)), Quaternion.identity); //dropa o item


            Destroy(this.gameObject);
        }
        GetComponent <CanvasGroup>().blocksRaycasts = true; //register hit on item again
    }