private void Awake()
 {
     rb        = GetComponent <Rigidbody2D>();
     inventory = GetComponent <PlayerCanvas>();
     SetGrayscale(true);
     menuCanvas.gameObject.SetActive(false);
 }
Beispiel #2
0
 public void ActivateClassPanel(PlayerCanvas.CharacterClass charClass)
 {
     for (int i = 0; i < (int)PlayerCanvas.CharacterClass.MAX; i++) {
         var classPanel = classPanels[i];
         classPanel.SetActive((int)charClass == i);
     }
 }
Beispiel #3
0
    private void Awake()
    {
        if (Instance == this)
        {
            //DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }

        _canvasRef = PlayerCanvas.Instance;
        _player    = ReInput.players.GetPlayer(_playerId);
        _playerRef = KyleplayerMove.Instance;

        _PauseMenu    = transform.GetChild(0).gameObject;
        _ControlsMenu = transform.GetChild(1).gameObject;

        _pauseMenuButtons = new List <Button>();
        for (int i = 0; i < _PauseMenu.transform.childCount; i++)
        {
            if (_PauseMenu.transform.GetChild(i).GetComponent <Button>())
            {
                _pauseMenuButtons.Add(_PauseMenu.transform.GetChild(i).gameObject.GetComponent <Button>());
            }
        }
        _currButton = 0;
        Debug.Log("init");
        _currScene = SceneManager.GetActiveScene().buildIndex;


        _pauseMenuButtons[_currButton].Select();
        _PauseMenu.SetActive(false);
        _ControlsMenu.SetActive(false);
    }
Beispiel #4
0
 private void SetupCachedComponents()
 {
     m_Manager = GetComponent <PlayerManager>();
     m_UI      = GetComponent <PlayerCanvas>();
     m_Weapon  = GetComponent <PlayerWeapon>();
     m_Inventory.SetCanvasUI(m_UI);
     //m_AudioManager = GetComponent<AudioManager>();
 }
Beispiel #5
0
    private void Awake()
    {
        myscript     = LevelSelection_Script.Instance;
        _playerRef   = GetComponent <KyleplayerMove>();
        _canvasRef   = PlayerCanvas.Instance;
        _PcurrHealth = _PmaxHealth;

        _currentHealthBar = GameObject.Find("HealthBar").GetComponent <Image>();
    }
Beispiel #6
0
 private void SetupCachedComponents()
 {
     m_Input     = GetComponent <PlayerInput>();
     m_Weapon    = GetComponent <PlayerWeapon>();
     m_Graphics  = GetComponent <PlayerGraphics>();
     m_UI        = GetComponent <PlayerCanvas>();
     m_Collider  = GetComponent <Collider2D>();
     m_Inventory = GetComponent <PlayerInventoryController>();
 }
 //Ensure there is only one PlayerCanvas
 void Awake()
 {
     if (canvas == null)
     {
         canvas = this;
     }
     else if (canvas != this)
     {
         Destroy(gameObject);
     }
 }
Beispiel #8
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
Beispiel #9
0
 /**
  * Thie method assigns singleton instance
  */
 void Awake()
 {
     // Check if canvas is null and assign static instance
     if (canvas == null)
     {
         canvas = this;
     }
     else if (canvas != this)
     {
         Destroy(gameObject);
     }
 }
Beispiel #10
0
 //
 public void initializeCanvas()
 {
     onDead();
     //active canvas
     canvas = GetComponentInChildren <PlayerCanvas>();
     if (canvas == null)
     {
         return;
     }
     canvas.Init(this);
     canvas.updatePlayerUI();
 }
Beispiel #11
0
    void CheckForBuilding()
    {
        RaycastHit hit;
        Ray        ray = new Ray(CheckPosition.position, Direction);

        if (Physics.Raycast(ray, out hit, 5f, BuildingMask))
        {
            canvasHit = hit.collider.GetComponent <PlayerCanvas>();

            canvasHit.AddToCanvas(hit.textureCoord, MyBrush);
            StartCoroutine(WaitForDestroy());
        }
    }
    public void PlayerLevelStart()
    {
        Debug.Log("level start called");
        transform.position = _startPos;
        _canvasRef         = PlayerCanvas.Instance;
        _ComboPartsParent  = _canvasRef.transform.GetChild(0).gameObject;
        _ComboText         = _ComboPartsParent.transform.GetChild(0).GetComponent <Text>();
        _DecayBar          = _ComboPartsParent.transform.GetChild(1).GetComponent <Image>();
        _pStats.FindHealthBar();

        _pauseRef = PauseMenu.Instance;
        _levelStartCycloneUnlock = _cycloneIsUnlocked;
        _levelStartDashUnlock    = _dashIsUnlocked;
    }
Beispiel #13
0
    public void PickUpItem(GameObject item)
    {
        FMOD_StudioSystem.instance.PlayOneShot("event:/player/weaponEquip02", transform.position, PlayerPrefs.GetFloat("MasterVolume") / 6f);
        GameObject temp = (GameObject)Instantiate(item, Vector3.zero, Quaternion.identity);

        temp.transform.parent        = playerInventoryRef.transform;
        temp.transform.localPosition = Vector3.zero;
        if (inventory.Count < 10 && (temp.GetComponent <Weapon>() != null || temp.GetComponent <Hack>() != null))
        {
            inventory.Add(temp.GetComponent <Item>());
        }
        else if (inventory.Capacity < 11)
        {
            inventory.Capacity = 11;
            inventory[10]      = temp.GetComponent <Item>();
        }
        else
        {
            inventory.Add(temp.GetComponent <Item>());
        }

        if (temp.GetComponent <Hack>() == null)
        {
            temp.SetActive(false);
        }
        else
        {
            temp.SetActive(true);
        }

        PlayerCanvas.UpdateInventory();

        if (item.GetComponent <Armor>() != null)
        {
            EquipArmor(temp);
        }

        if (activeWeapon == null && item.GetComponent <Weapon>() != null)
        {
            SetActiveItem(0);
        }

        if (activeHack == null && item.GetComponent <Hack>() != null)
        {
            SetActiveItem(1);
        }

        ActionEventInvoker.primaryInvoker.invokeAction(new PlayerAction(temp.GetComponent <Item> ().getDirectObject(), ActionType.PICKED_UP_OBJECT));
    }
    void DrawOnCanvas()
    {
        RaycastHit hit;
        Ray        ray = new Ray(transform.position, Direction);

        if (Physics.Raycast(ray, out hit, 10f, CanvasMask))
        {
            textureCoord = hit.textureCoord;
            hitCanvas    = hit.collider.GetComponent <PlayerCanvas>();
        }

        if (hitCanvas != null)
        {
            hitCanvas.AddToCanvas(textureCoord, MyBrush);
        }
    }
Beispiel #15
0
    // Use this for initialization
    protected void Start()
    {
        if (hitInfo == null)
        {
            hitInfo = Resources.Load <GameObject>("Info/HitInfo");
        }
        if (byteObject == null)
        {
            byteObject = Resources.Load <GameObject>("Info/Byte");
        }

        int minversionInt = Utility.ComparableVersionInt(minVersion);
        int maxversionInt = Utility.ComparableVersionInt(maxVersion);
        int minRange      = Mathf.Min(Mathf.Max(minversionInt, Utility.ComparableVersionInt(Player.version) - 10), maxversionInt);
        int maxRange      = Mathf.Max(Mathf.Min(Utility.ComparableVersionInt(Player.version) + 2, maxversionInt), minversionInt);

        int versionInt = (Random.Range(minRange, maxRange) % 100) + 1;

        Debug.Log(this.name + ": versionint = " + versionInt);
        this.maxHP *= (int)((versionInt) * (healthScale + 1));
        Debug.Log(this.name + ": maxhp = " + this.maxHP);
        this.baseAttackDamage += (versionInt) * (attackScale);
        Debug.Log(this.name + ": attack = " + this.baseAttackDamage);
        this.baseHealthRegen += (versionInt) * (healthRegenScale);
        this.baseAttackSpeed /= (versionInt) * (attackSpeedScale + 1);
        this.version          = Utility.ModVersionBy("1.0.0", versionInt);
        Debug.Log(this.name + ": version = " + version);
        hp = maxHP;
        if (possibleItemDrops.Count != possibleItemDropsChance.Count)
        {
            Debug.LogWarning("Hey dummy! You need to have equal number of item drops and item drop chances!");
        }
        else
        {
            for (int i = 0; i < possibleItemDrops.Count; i++)
            {
                itemDrops.Add(possibleItemDrops[i], possibleItemDropsChance[i]);
            }
        }

        currentEffect = Effect.None;

        PlayerCanvas.RegisterEnemyHealthBar(this.gameObject);

        speedRandomness = Random.value * 5f;
    }
Beispiel #16
0
    public void Start()
    {
        _Player                 = ReInput.players.GetPlayer(_playerId);
        _playerCam              = FindObjectOfType <PlayerCamera>().gameObject.GetComponent <Camera>();
        _myPos                  = Vector3.zero;
        _myCanvas               = PlayerCanvas.Instance;
        _myCanvas.SetGameReset += InteractableReset;
        GameObject _ImageRef = Instantiate <GameObject>(InteractImagePrefab, _myPos, _myCanvas.transform.rotation, _myCanvas.transform);

        _myImage = _ImageRef;
        _myImage.SetActive(false);

        _playerRef = KyleplayerMove.Instance;
        switch (_whatAmI)
        {
        case TypeOfObject.DOOR:
            break;

        case TypeOfObject.POTION:
            transform.parent = null;
            break;

        case TypeOfObject.UPGRADE:
            _winRef = FindObjectOfType <WinCondition>();
            GameObject _killtext = Instantiate <GameObject>(_KillsTextPrefab, _myPos, _myCanvas.transform.rotation, _myCanvas.transform);
            _KillsToUnlockText = _killtext;
            _KillsToUnlockText.SetActive(false);

            transform.parent = null;
            break;

        case TypeOfObject.PUZZLE:
            break;

        case TypeOfObject.Mural:
            _MuralObj.SetActive(false);
            _MuralState = false;
            break;

        default:
            break;
        }
    }
Beispiel #17
0
    Vector3 GetDrawPointVector()
    {
        RaycastHit hit;

        //Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        Ray ray = new Ray(DrawPivot.position, direction);

        Debug.DrawRay(DrawPivot.position, direction, Color.red);

        if (Physics.Raycast(ray, out hit, 100f, DrawMask))
        {
            textureCoord = hit.textureCoord;
            hitCanvas    = hit.collider.GetComponent <PlayerCanvas>();

            return(hit.point);
        }

        //Clear();
        return(Vector3.zero);
    }
Beispiel #18
0
 private void SetupCachedReferences()
 {
     m_WeaponObject = transform.Find(Consts.WEAPON_OBJECT_NAME).gameObject;
     m_PlayerCanvas = transform.GetComponentInChildren <PlayerCanvas>();
 }
Beispiel #19
0
 PlayerCanvas()
 {
     singleton = this;
 }
        public static void Postfix(PlayerCanvas __instance)
        {
            if (Main.IsConnected)
            {
                try
                {
                    WriteLog.General("Da parent GameObject is " + __instance.gameObject.gameObject.transform.parent.gameObject.name + " in scene " + __instance.gameObject.scene.name);
                    foreach (GameObject gameObject in SceneManager.GetActiveScene().GetRootGameObjects())
                    {
                        WriteLog.General("Current GameObject is " + gameObject.name + " in scene " + gameObject.scene.name);
                        if (gameObject.name == "AITargets")
                        {
                            UnityEngine.Object.Destroy(gameObject);
                        }
                        if (gameObject.name == "Players")
                        {
                            WriteLog.General("Found players gameobject");

                            List <string> playersList = new List <string>();
                            Main          clientInst  = InstanceKeeper.GetMainClient();
                            playersList = clientInst.opponentsNames;
                            List <string> addedNames = new List <string>();
                            int           count      = gameObject.transform.GetChildCount();
                            WriteLog.General("Found " + count + " children");
                            for (int counter = 0; counter < count; counter++)
                            {
                                WriteLog.General("Current player : " + counter);
                                foreach (Component component in gameObject.transform.GetChild(counter).gameObject.GetComponentsInChildren <Component>())
                                {
                                    WriteLog.General("TEMP, for testing: found sub-component called " + component.name + " of type " + component.GetType().Name + " and pos " + component.transform.position);
                                }
                                OnShipUI playerUI = gameObject.transform.GetChild(counter).gameObject.GetComponentInChildren <OnShipUI>();
                                if (playerUI == null /* && gameObject.transform.GetChild(counter).gameObject.name=="Player (Clone)"*/)
                                {
                                    WriteLog.General("Found an AI player");
                                    gameObject.transform.GetChild(counter).gameObject.GetComponentInChildren <VehicleBehaviour>().SetAI(false);
                                    foreach (string name in playersList)
                                    {
                                        if (!addedNames.Contains(name) && (File.ReadAllText("username.txt") != name))
                                        {
                                            WriteLog.General("Adding player: " + name);
                                            gameObject.transform.GetChild(counter).gameObject.AddComponent <ZeroGPlayer>();
                                            ZeroGPlayer playerLocalName = gameObject.transform.GetChild(counter).gameObject.GetComponent <ZeroGPlayer>();
                                            playerLocalName.PlayerName = name;
                                            addedNames.Add(name);
                                            goto Endforeach;
                                        }
                                    }
                                    Endforeach :;
                                    clientInst.playerShips.Add(gameObject.transform.GetChild(counter).gameObject);
                                }
                            }
                            InstanceKeeper.SetMainClient(clientInst);
                        }
                    }
                }
                catch (Exception ex)
                {
                    WriteLog.Error("Error while trying to get GameObject, : " + ex.Message + ex.StackTrace);
                }
            }
            else
            {
            }
        }
Beispiel #21
0
 public void SetCanvasUI(PlayerCanvas canvas)
 {
     m_UI = canvas;
 }
 public void Awake()
 {
     instance            = this;
     playerProfilePanels = new List <PlayerProfilePanel>();
 }
Beispiel #23
0
    void Update()
    {
        PlayerCanvas.ClearHint();
        if (!GameManager.FirstPersonMode)
        {
            return;
        }

        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, RaycastRange, ObjectsLayer, QueryTriggerInteraction.Collide))
        {
            if (!hit.collider.CompareTag(InteractiveTag))
            {
                return;
            }

            _currentSelection = hit.collider.GetComponent <InteractiveObject>();
            if (_currentSelection != null)
            {
                PlayerCanvas.ShowHint(_currentSelection.Title.ToUpper());
            }

            if (HasSelection)
            {
                if (Input.GetButtonDown(UseCmd))
                {
                    if (hit.distance > InteractionRange)
                    {
                        DialogueManager.PlayDialogue("toofar");
                        return;
                    }
                    _currentSelection.Use();
                    _currentSelection = null;
                }
                else if (Input.GetButtonDown(ExamineCmd))
                {
                    if (hit.distance > InteractionRange)
                    {
                        DialogueManager.PlayDialogue("toofar");
                        return;
                    }
                    _currentSelection.Examine();
                    _currentSelection = null;
                }
                else if (Input.GetButtonDown(CombineCmd))
                {
                    if (hit.distance > InteractionRange)
                    {
                        DialogueManager.PlayDialogue("toofar");
                        return;
                    }

                    _currentSelection.Combine();
                    _currentSelection = null;
                }
            }
        }
        else
        {
            _currentSelection = null;
        }
    }
Beispiel #24
0
 public static void SetTargetClass(PlayerCanvas.CharacterClass charClass)
 {
     targetClass = charClass;
 }
 /**
  * Initialize the mover
  **/
 void Start()
 {
     move   = GetComponent <CameraMover>();
     player = GameObject.Find("PlayerCanvas").GetComponent <PlayerCanvas> ();
 }
Beispiel #26
0
    void Start()
    {
        weaponRef = GameObject.Find("PlayerWeaponObj");
        if (PersistentInfo.playerName != null && !PersistentInfo.playerName.Equals(""))
        {
            if (PersistentInfo.playerName.Contains("\n"))
            {
                PersistentInfo.playerName = PersistentInfo.playerName.Substring(0, PersistentInfo.playerName.Length - 1);
            }
            this.name = PersistentInfo.playerName;
        }
        else if (PersistentInfo.saveFile > 0 && !MasterDriver.bossLevel)
        {
            MasterDriver.Instance.loadGame = true;
        }

        levelUpParticles = GameObject.Find("LevelUpParticles").GetComponent <ParticleSystem>();

        //Need to figure out a better way to load the hitinfo prefab
        hitInfo = Resources.Load <GameObject>("Info/HitInfo");

        //setting initial integrity and rma values
        integrity = maxIntegrity;
        rma       = maxrma;

        //initializing the references to the player inventory, armor points, and weaponhand
        playerInventoryRef = GameObject.Find("PlayerInventory");
        playerPos          = transform;
        bytesToNextVersion = ((int.Parse(version.Split('.')[0])) * 10 + (int.Parse(version.Split('.')[1])) * 50) * levelUpSpeedScale;

        //setting up inventory
        inventory = new List <Item>();
        if (weaponRef.transform.childCount != 0)
        {
            inventory.Add(weaponRef.transform.GetChild(0).GetComponent <Item>());
        }
        for (int i = 0; i < playerInventoryRef.transform.childCount; i++)
        {
            inventory.Add(playerInventoryRef.transform.GetChild(i).GetComponent <Item>());
        }

        //setting up playerarmor
        playerArmor = new GameObject[4];

        leftUpLegRef     = transform.Find("Character1_Reference/Character1_Hips/Character1_LeftUpLeg").GetComponent <Transform>();
        rightUpLegRef    = transform.Find("Character1_Reference/Character1_Hips/Character1_RightUpLeg").GetComponent <Transform>();
        leftLegRef       = transform.Find("Character1_Reference/Character1_Hips/Character1_LeftUpLeg/Character1_LeftLeg").GetComponent <Transform>();
        rightLegRef      = transform.Find("Character1_Reference/Character1_Hips/Character1_RightUpLeg/Character1_RightLeg").GetComponent <Transform>();
        leftFootRef      = transform.Find("Character1_Reference/Character1_Hips/Character1_LeftUpLeg/Character1_LeftLeg/Character1_LeftFoot").GetComponent <Transform>();
        rightFootRef     = transform.Find("Character1_Reference/Character1_Hips/Character1_RightUpLeg/Character1_RightLeg/Character1_RightFoot").GetComponent <Transform>();
        spineRef         = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine").GetComponent <Transform>();
        leftShoulderRef  = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_LeftShoulder").GetComponent <Transform>();
        rightShoulderRef = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_RightShoulder").GetComponent <Transform>();
        leftArmRef       = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_LeftShoulder/Character1_LeftArm").GetComponent <Transform>();
        leftForearmRef   = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_LeftShoulder/Character1_LeftArm/Character1_LeftForeArm").GetComponent <Transform>();
        leftHandRef      = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_LeftShoulder/Character1_LeftArm/Character1_LeftForeArm/Character1_LeftHand").GetComponent <Transform>();
        rightArmRef      = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_RightShoulder/Character1_RightArm").GetComponent <Transform>();
        rightForearmRef  = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_RightShoulder/Character1_RightArm/Character1_RightForeArm").GetComponent <Transform>();
        rightHandRef     = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_RightShoulder/Character1_RightArm/Character1_RightForeArm/Character1_RightHand").GetComponent <Transform>();
        headRef          = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_Neck/Character1_Head").GetComponent <Transform>();

        //setting up initial weapon and hack (not the best way to do this since
        //it requires that the first item in the inventory prefab needs to be a hack
        if (inventory.Count > 1)
        {
            activeWeapon = (Weapon)inventory[0];
            activeHack   = (Hack)inventory[1];
            SetActiveItem(0);
            SetActiveItem(1);
        }

        if (!Application.loadedLevel.Equals("KartikTesting"))
        {
            respawnLoc = transform.position;
        }

        //sets up quickaccessitems and makes the canvas update the inventory ui
        PlayerCanvas.UpdateInventory();
//		Debug.LogError(GetName());
    }