void Start()
    {
        this.stats_manager   = GameObject.FindGameObjectWithTag("Manager").GetComponent <Stats_Manager>();
        this.input_manager   = GameObject.FindGameObjectWithTag("Manager").GetComponent <InputManager>();
        this.player_movement = this.GetComponent <PlayerMovementScript>();

        if (stats_manager == null)
        {
            Debug.Log("ERROR: Can't find stats manager! Source: Player");
        }
        else
        {
            this.playerHealth = stats_manager.GetPlayerHealth();

            this.playerStamina = stats_manager.GetPlayerStamina();

            this.playerArmor = stats_manager.GetPlayerArmor();

            this.MAX_ALLOWED_PLAYER_HEALTH = stats_manager.GetMaxPlayerHealth(); //We are going to save playerHealth so it must be separate.

            this.MAX_ALLOWED_PLAYER_STAMINA = stats_manager.GetMaxPlayerStamina();

            this.timeSinceLastStaminaDrain = this.defaultTimeSinceLastStaminaDrain;

            Debug.Log("PLAYER HEALTH: " + playerHealth + " PLAYER STAMINA: " + playerStamina + " PLAYER ARMOR: " + playerArmor);

            if (playerArmor == 0 || playerStamina == 0 || playerHealth == 0)
            {
                Debug.Log("ERROR: Can't get player stats on player.");
            }
        }
    }
Esempio n. 2
0
 public void PickUpWeapon(PlayerScript p)
 {
     player     = p;
     playerMove = player.GetComponent <PlayerMovementScript>();
     beingHeld  = true;
     attacking  = false;
 }
        public void TestPlayerMovementScript()
        {
            Vector3 firstTest  = PlayerMovementScript.GetInputDir(10, 0);
            Vector3 secondTest = PlayerMovementScript.GetInputDir(10, 10);
            Vector3 thirdTest  = PlayerMovementScript.GetInputDir(4, 1);
            Vector3 fourthTest = PlayerMovementScript.GetInputDir(0, 10);
            Vector3 fifthTest  = PlayerMovementScript.GetInputDir(1, 4);
            Vector3 sixthTest  = PlayerMovementScript.GetInputDir(-10, 0);

            Vector3 seventhTest = PlayerMovementScript.GetInputDir(0, -10);
            Vector3 eighthTest  = PlayerMovementScript.GetInputDir(-4, 1);
            Vector3 ninthTest   = PlayerMovementScript.GetInputDir(1, -4);
            Vector3 tenthTest   = PlayerMovementScript.GetInputDir(-1, -1);

            Assert.AreEqual(new Vector3(1, 0, 0), firstTest);
            Assert.AreEqual(new Vector3(.5f, 0, .5f), secondTest);
            Assert.AreEqual(new Vector3(.8f, 0, .2f), thirdTest);
            Assert.AreEqual(new Vector3(0, 0, 1), fourthTest);
            Assert.AreEqual(new Vector3(.2f, 0, .8f), fifthTest);
            Assert.AreEqual(new Vector3(-1, 0, 0), sixthTest);
            Assert.AreEqual(new Vector3(0, 0, -1), seventhTest);
            Assert.AreEqual(new Vector3(-.8f, 0, .2f), eighthTest);
            Assert.AreEqual(new Vector3(.2f, 0, -.8f), ninthTest);
            Assert.AreEqual(new Vector3(-.5f, 0, -.5f), tenthTest);
        }
Esempio n. 4
0
 public void DropWeapon()
 {
     player     = null;
     playerMove = null;
     beingHeld  = false;
     attacking  = false;
 }
Esempio n. 5
0
    //bool damaged;


    void Start()
    {
        //anim = GetComponent<Animator>();
        playerMovement  = GetComponent <PlayerMovementScript>();
        playerAttacking = GetComponent <PlayerBasicAttackScript>();
        currentHealth   = startingHealth;
    }
Esempio n. 6
0
    // Initialize references to player transform and the player script
    void Start()
    {
        var player = GameObject.FindWithTag("Player");

        playerTransform = player.transform;
        playerScript    = player.GetComponent <PlayerMovementScript>();
    }
Esempio n. 7
0
 public void DropWeapon()
 {
     player = null;
     playerMove = null;
     beingHeld = false;
     attacking = false;
 }
Esempio n. 8
0
 public void PickUpWeapon(PlayerScript p)
 {
     player = p;
     playerMove = player.GetComponent<PlayerMovementScript>();
     beingHeld = true;
     attacking = false;
 }
 /**
  * Awake- Used by Unity for initialization
  * Finds all component children that this player has and caches them
  */
 void Awake()
 {
     movementScript = transform.FindChild("MovementController").GetComponent <PlayerMovementScript> ();
     if (movementScript == null)
     {
         Debug.LogError("Could not load Player Movement Script");
     }
     inputScript = transform.FindChild("InputController").GetComponent <PlayerInputScript> ();
     if (inputScript == null)
     {
         Debug.LogError("Could not load Player Input Script");
     }
     networkScript = transform.FindChild("NetworkController").GetComponent <NetworkControllerScript> ();
     if (inputScript == null)
     {
         Debug.LogError("Could not load Network Controller Script");
     }
     visionScript = transform.FindChild("VisionController").GetComponent <VisionControllerScript> ();
     if (visionScript == null)
     {
         Debug.LogError("Could not load Vision Controller Script");
     }
     environmentScript = transform.FindChild("EnvironmentController").GetComponent <PlayerEnvironmentController> ();
     if (environmentScript == null)
     {
         Debug.LogError("Could not load Player Environment Controller Script");
     }
     healthScript = transform.FindChild("HealthController").GetComponent <PlayerHealthScript> ();
     if (healthScript == null)
     {
         Debug.LogError("Could not load Player Health Script");
     }
 }
Esempio n. 10
0
 // Start is called before the first frame update
 void Start()
 {
     picking    = false;
     controls   = GameObject.FindObjectOfType <PlayerMovementScript>() as PlayerMovementScript;
     layerMasks = LayerMask.GetMask("Ground");
     plane      = new Plane(Vector3.up, controls.transform.position);
 }
 void Start()
 {
     playerAnimator        = GlobalData.PlayerAnimator;
     playerMovementScript  = GlobalData.PlayerMovementScript;
     interactableLayerMask = 1 << (int)Mathf.Log(GlobalData.InteractableLayerMask.value, 2);
     enemiesLayerMask      = 1 << (int)Mathf.Log(GlobalData.EnemiesLayerMask.value, 2);
     soundManagerScript    = GlobalData.SoundManagerScript;
 }
Esempio n. 12
0
 void Awake()
 {
     cameraTransform      = GameObject.FindWithTag("MainCamera").transform;
     countToThrow         = -1;
     playerTransform      = GameObject.FindWithTag("Player").transform;
     playerMovementScript = GameObject.FindWithTag("Player").GetComponent <PlayerMovementScript>();
     cameraObject         = GameObject.FindWithTag("MainCamera");
 }
Esempio n. 13
0
    void FixedUpdate()
    {
        Vector3 dir = PlayerMovementScript.GetInputDir(Input.GetAxis("Horizontal"),Input.GetAxis("Vertical"));

        Vector3 acceleration = dir * accelSpeed;

        rb.AddForce(acceleration, ForceMode.Force);
    }
Esempio n. 14
0
    private void Impact(Collision2D col)
    {
        PlayerMovementScript player = col.gameObject.GetComponent <PlayerMovementScript>();

        if (player)
        {
            Debug.Log("Damage player" + player);
        }
    }
 private void Start()
 {
     m_animator = GetComponent <Animator>();
     m_movement = GetComponent <PlayerMovementScript>();
     m_combat   = GetComponent <PlayerCombatScript>();
     m_movement.BindState(m_state);
     m_combat.BindState(m_state);
     m_curHealth = health;
 }
    public void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");
        playerMovement = player.GetComponent<PlayerMovementScript>();

        // TODO this position and rotation is baked, extract it
        initialOffset = new Vector3(2.5f, 10.0f, -7.5f);
        offset = initialOffset;
    }
    // Use this for initialization
    void Start()
    {
        player = GameObject.FindWithTag("Player").GetComponent <PlayerMovementScript> ();
        var lBtnScript = leftBtn.GetComponent <PlayerMovementButton> ();
        var rBtnScript = rightBtn.GetComponent <PlayerMovementButton> ();

        lBtnScript.handler = () => { player.MoveLeft(); };
        rBtnScript.handler = () => { player.MoveRight(); };
    }
Esempio n. 18
0
 // Use this for initialization
 void Start()
 {
     sound     = GameObject.Find("Main Camera").GetComponent <SoundPlayer>();
     inventory = GetComponent <PlayerInventory> ();
     input     = GetComponent <InputScript> ();
     PMS       = GetComponent <PlayerMovementScript> ();
     input.assignXButton(UseItem, null);
     input.assignAButton(Attack, null);
 }
Esempio n. 19
0
    private void GetComponents()
    {
        PlayerInputScript    = GetComponent <PlayerInputScript>();
        PlayerMovementScript = GetComponent <PlayerMovementScript>();

        Animator       = GetComponent <Animator>();
        SpriteRenderer = GetComponent <SpriteRenderer>();
        Rb2d           = GetComponent <Rigidbody2D>();
    }
Esempio n. 20
0
    public void Start()
    {
        player         = GameObject.FindGameObjectWithTag("Player");
        playerMovement = player.GetComponent <PlayerMovementScript>();

        // TODO this position and rotation is baked, extract it
        initialOffset = new Vector3(2.5f, 10.0f, -7.5f);
        offset        = initialOffset;
    }
Esempio n. 21
0
 private void Awake()
 {
     movementScript = transform.GetComponent <PlayerMovementScript>();
     if (movementScript == null)
     {
         Debug.LogError("PlayerControls: player movement script not found!");
     }
     gun.choosedWeapon = gun.we1.weapon[0];
 }
Esempio n. 22
0
    //checks the enemys hit onto player and the damage value
    private void OnTriggerEnter2D(Collider2D hit)
    {
        PlayerMovementScript player = hit.GetComponent <PlayerMovementScript>();

        if (player != null)
        {
            player.DamageTaken(enemyDamage);
        }
    }
Esempio n. 23
0
 void Awake()
 {
     input          = GameObject.FindGameObjectWithTag("Manager").GetComponent <InputManager>();
     stats          = GameObject.FindGameObjectWithTag("Manager").GetComponent <Stats_Manager>();
     playerMovement = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovementScript>();
     headpos        = transform.localPosition;
     midpointY      = transform.localPosition.y;
     midpointX      = transform.localPosition.x;
 }
Esempio n. 24
0
 void Start()
 {
     player = GameObject.FindWithTag("Player").GetComponent <PlayerMovementScript>();
     objectPositions.ToList().ForEach(pos =>
     {
         var tetherIndicator = Instantiate(TetherIndicatorPrefab, pos, Quaternion.identity) as GameObject;
         tetherIndicator.transform.localScale *= tetherAreaSize;
     });
 }
Esempio n. 25
0
 void Awake()
 {
     playerScript = this.gameObject.GetComponent<PlayerMovementScript>();
     PointerLeftDownHandler.leftPressed = false;
     PointerRightDownHandler.rightPressed = false;
     rightPressed = false;
     leftPressed = false;  
     Invoke("CanPress", 0.5f);
 }
Esempio n. 26
0
    private void Impact(Collision2D col)
    {
        Destroy(gameObject);
        PlayerMovementScript player = col.gameObject.GetComponent <PlayerMovementScript>();

        if (player)
        {
        }
    }
Esempio n. 27
0
    public void DragonDead()
    {
        UIController.UpdatePages(UIMode.Vitory);
        bTimerActive = false;
        PlayerMovementScript playerMovement = FindObjectOfType <PlayerMovementScript>();

        playerMovement.GetAnimator().Play("Win");
        Vector3 Direction = bossBehaviour.transform.position - playerMovement.transform.position;

        if (Direction.x > 0)
        {
            if (playerMovement.GetSkeleton().Skeleton.ScaleX < 0)
            {
                playerMovement.GetSkeleton().Skeleton.ScaleX = -playerMovement.GetSkeleton().Skeleton.ScaleX;
            }
        }
        else
        {
            if (playerMovement.GetSkeleton().Skeleton.ScaleX > 0)
            {
                playerMovement.GetSkeleton().Skeleton.ScaleX = -playerMovement.GetSkeleton().Skeleton.ScaleX;
            }
        }

        if (PrincePrefab)
        {
            princeGO = Instantiate(PrincePrefab, bossBehaviour.transform.position, Quaternion.identity);

            GameObject VFX = Instantiate(WinVFX, bossBehaviour.transform.position, Quaternion.identity);
            Destroy(VFX, 5.0f);
            bossBehaviour.gameObject.SetActive(false);

            if (princeGO)
            {
                SkeletonAnimation PrinceSkeleton = princeGO.GetComponentInChildren <SkeletonAnimation>();
                if (Direction.x > 0)
                {
                    if (PrinceSkeleton.Skeleton.ScaleX < 0)
                    {
                        PrinceSkeleton.Skeleton.ScaleX = -PrinceSkeleton.Skeleton.ScaleX;
                    }
                }
                else
                {
                    if (PrinceSkeleton.Skeleton.ScaleX > 0)
                    {
                        PrinceSkeleton.Skeleton.ScaleX = -PrinceSkeleton.Skeleton.ScaleX;
                    }
                }
            }
        }

        cameraBehaviour.FocusCamera(playerMovement.transform.position, bossBehaviour.transform.position);
    }
Esempio n. 28
0
    // Use this for initialization
    void Start()
    {
        gameManager  = GameObject.Find("GameManager");
        scoreManager = gameManager.GetComponent <ScoreManagerScript> ();
        hms          = gameManager.GetComponent <HealthManagerScript> ();
        pms          = gameObject.GetComponent <PlayerMovementScript> ();
        healthText   = GameObject.Find("Health").GetComponent <Text> ();

        healthText.text = "Health Remaining: " + hms.BoxHealth;
        healthTextColorChanger();
    }
    public void WinGhunter(string reasonForWinning)
    {
        GameObject CanvasPlayerUIObject = GameObject.Find("CanvasPlayerUI");
        // Get the player
        PlayerMovementScript ghunterMoveScript = GameObject.Find("Ghunter").GetComponent <PlayerMovementScript>();

        // Enabling right UI elements
        CanvasPlayerUIObject.transform.Find("GhunterWon").gameObject.SetActive(true);
        CanvasPlayerUIObject.transform.Find("GhunterWon").transform.Find(reasonForWinning).gameObject.SetActive(true);
        ghunterMoveScript.CanMove = false;
    }
    void Awake()
    {
        playerMovement = GetComponent <PlayerMovementScript>();

        currentHealth = startingHealth;

        playerAudio = GetComponent <AudioSource>();

        anim = GetComponent <Animator>();

        healthSlider.value = currentHealth;
    }
Esempio n. 31
0
    void Awake()
    {
        moveScript  = GameObject.FindObjectOfType <PlayerMovementScript>();
        ModelOrigin = gunModel.transform.localPosition;

        if (!GameSettings.Instance)
        {
            return;
        }

        Shoot = GameSettings.Instance.Fire;
    }
Esempio n. 32
0
    void Start()
    {
        animator = GetComponent <Animator>();
        isDead   = false;
        scriptPlayerMovementScript = GetComponent <PlayerMovementScript>();

        HP             = startHearts * healthPerHeart;
        maxHP          = HP;
        maxHPavailable = maxHearts * healthPerHeart;

        checkHealthAmount();
    }
Esempio n. 33
0
 //[SerializeField]
 //internal PlayerAnimation animationScript;
 //[SerializeField]
 //internal PlayerHealthController healthScript;
 // Start is called before the first frame update
 void Start()
 {
     //Initialize things, set necessary variables.
     inputScript     = GetComponent <PlayerInputScript>();
     movementScript  = GetComponent <PlayerMovementScript>();
     climbingScript  = GetComponent <PlayerClimbingScript>();
     collisionScript = GetComponent <PlayerCollisionScript>();
     //animationScript = GetComponent<PlayerAnimation>();
     //healthScript = GetComponent<PlayerHealthController>();
     playerTransform = GetComponent <Transform>();
     GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY;
     GetComponent <MeshCollider>().convex   = true;
 }
Esempio n. 34
0
    public void SelectPlayer(PlayerMovementScript player)
    {
        if (selectedPlayer != null)
        {
            //Reset the material on the select player
            selectedPlayer.gameObject.GetComponent <MeshRenderer>().material = unSelectedMat;
            selectedPlayer.PlayerDeselected();
        }

        //select the player
        selectedPlayer = player;
        selectedPlayer.gameObject.GetComponent <MeshRenderer>().material = selectedMat;
    }
Esempio n. 35
0
 // Use this for initialization
 void Start()
 {
     randomSeed = Random.Range(0.0f, 50.0f);
     playerStats.randomSeed = Random.Range(0.0f, 50.0f);
     playerOneMovement = (PlayerMovementScript)GameObject.Find ("Player1").GetComponent(typeof(PlayerMovementScript));
 }
Esempio n. 36
0
 // Use this for initialization
 void Start()
 {
     movement = player.GetComponent<PlayerMovementScript> ();
     resources = player.GetComponent<PlayerResources> ();
     NewApocalypse ();
     currentApocalypse.GetComponent<PolygonGenerator> ().player = this.player;
 }
Esempio n. 37
0
 protected virtual void Awake()
 {
     player = GetComponent<PlayerMovementScript>();
 }