Exemplo n.º 1
0
    void FixedUpdate()
    {
        if (isShaking)
        {
            float randomShakeX = Random.Range(-intensity, intensity);
            float randomShakeY = Random.Range(-intensity, intensity);

            transform.position = new Vector3(baseX + randomShakeX, baseY + randomShakeY, baseZ);

            shakes--;

            if (shakes <= 0)
            {
                isShaking          = false;
                transform.position = new Vector3(baseX, baseY, baseZ);


                PlayerMechanics PM = GameObject.Find("Player Balloon").GetComponent <PlayerMechanics> ();
                PM.HasShaken = true;
            }
            else
            {
                PlayerMechanics PM = GameObject.Find("Player Balloon").GetComponent <PlayerMechanics> ();
                PM.HasShaken = false;
            }
        }
    }
Exemplo n.º 2
0
 /// <summary>
 ///  Define the overrideable CleanUpMechanic. Reset the particle for the coffeeBomb.
 /// </summary>
 /// <param name="playerMechanics"></param>
 public override void CleanUpMechanic(PlayerMechanics playerMechanics)
 {
     i     = 0;
     iBomb = null;
     playerMechanics.player.transform.position    = playerMechanics.player.teleportPoint.position;
     playerMechanics.player.transform.eulerAngles = new Vector3(0, 0, 0);
 }
Exemplo n.º 3
0
    void Drop()
    {
        if (playerMechanics != null && playerMechanics.GetComponent <MovementScript2D>().playerState == PlayerStates.idle)
        {
            //Check for the button press
            if (playerMechanics.itemPickedUp == this.gameObject)
            {
                //If the item is picked up, then check for the button press for pickup
                if (Input.GetKeyDown(KeyCode.P) || VirtualJoystick.pickUpButtonDown)
                {
                    Debug.Log("Dropping");
                    //Material must be set to the default material on drop
                    spriteRenderer.material = defaultMaterial;


                    //If all the conditions are satisfied, then pick up the item
                    pickedUp = false;
                    playerMechanics.itemPickedUp = null;

                    //disable the trigger and set it's parent as the player
                    gameObject.GetComponent <BoxCollider2D>().enabled = true;
                    gameObject.transform.parent = null;
                    playerMechanics             = null;

                    //Change virtual joystick sprite
                    VirtualJoystick.pickUpButton.GetComponent <UnityEngine.UI.Image>().sprite = VirtualJoystick.pickUpButton.GetComponent <PickUpButton>().pickupSprite;

                    //After Dropping, disable the special actions button and activate the pickup button
                    //VirtualJoystick.itemSpecialActionButton.SetActive(false);
                    //VirtualJoystick.pickUpButton.SetActive(false);
                    //VirtualJoystick.pickUpButton.SetActive(true);
                }
            }
        }
    }
Exemplo n.º 4
0
        private void Update()
        {
            if (client.LocalPlayer == null || !client.LocalPlayer.PlayerObject)
            {
                return;
            }

            if (!mechanics)
            {
                mechanics = client.LocalPlayer.PlayerObject.GetComponent <PlayerMechanics>();
            }

            var wep = mechanics.CurrentWeapon;

            if (!wep)
            {
                return;
            }

            if (wep.Ammo == lastAmmoCount)
            {
                return;
            }

            SetAmmo(wep.Ammo);
        }
Exemplo n.º 5
0
    public void InitGame()
    {
        this.gameUI                 = GameObject.Find("GameUI").GetComponent <GameUIManager>();
        this.environment            = GameObject.Find("Environment");
        this.playerObject           = this.environment.transform.GetChild(1).GetChild(0).gameObject;
        this.enemyObject            = this.environment.transform.GetChild(1).GetChild(1).gameObject;
        this.playerStats            = playerObject.GetComponent <PlayerMechanics>();
        this.enemyStats             = enemyObject.GetComponent <EnemyMechanics>();
        this.instructionsGameObject = GameObject.Find("Tiles");
        this.instructionsGameObject.SetActive(false);
        this.arenaGameObject = environment.transform.GetChild(0).gameObject;
        this.arenaCells      = new GameObject[6, 6];
        this.arenaCellData   = new int[6, 6];

        for (int i = 0; i < this.arenaCells.GetLength(0); i++)
        {
            for (int j = 0; j < this.arenaCells.GetLength(1); j++)
            {
                this.arenaCells[i, j] = this.arenaGameObject.transform.GetChild(i).GetChild(j).gameObject;
                if (this.arenaCells[i, j].transform.childCount > 0)
                {
                    arenaCellData[i, j] = 1;
                }
                else
                {
                    arenaCellData[i, j] = 0;
                }
            }
        }

        StartCoolDownTimer(10);
    }
Exemplo n.º 6
0
    void Shoot()
    {
        ammo--;
        RaycastHit hit;

        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
        {
            Debug.Log(hit.transform.name);
            PlayerMechanics player = hit.transform.GetComponent <PlayerMechanics>();
            ShootableNPC    npc    = hit.transform.GetComponent <ShootableNPC>();
            if (player != null)
            {
                if (player.name == this.name)
                {
                    return;
                }
                CmdDealDamage(damage, player.name);
                if (player.death)
                {
                    player.kills += 1;
                    Debug.Log("The player killed another player!");
                }
            }
            if (npc != null)
            {
                npc.TakeDamage(damage);
                if (npc.death)
                {
                    kills += 1;
                    Debug.Log("The player killed an NPC!");
                }
            }
        }
    }
Exemplo n.º 7
0
    public override void Activate(PlayerMechanics player)
    {
        AudioManager.Instance.Play("Mechanic");

        GameObject copy = Instantiate(platform, player.transform.position, Quaternion.identity);

        Destroy(copy, duration);
    }
Exemplo n.º 8
0
    void CmdDealDamage(int damage, string playerName)
    {
        Debug.LogError($"Player {this.name}, wants to hit {playerName}");
        PlayerMechanics player = GameObject.Find(playerName).GetComponent <PlayerMechanics>();

        Debug.LogError(player);
        player.TakeDamage(this, damage);
    }
Exemplo n.º 9
0
 /// <summary>
 /// if this is the first time called while activated, spawn a coffee infront of the player. All Coffee Values are set on the prefab included.
 /// </summary>
 /// <param name="playerMechanics"></param>
 private void Spawn(PlayerMechanics playerMechanics)
 {
     if (i == 0)
     {
         tempCoffee = null;
         tempCoffee = Instantiate(coffee, (playerMechanics.player.transform.position + playerMechanics.player.transform.forward.Multiply(playerMechanics.player.coffeeOffset)), Quaternion.Euler(-90, 0, 0));
         i++;
     }
 }
Exemplo n.º 10
0
    /// <summary>
    ///  Define the overrideable ExecuteMechanic. Save the original maxSpeed for the reset and then exponentially increase the maxSpeed.
    /// </summary>
    /// <param name="playerMechanics"></param>
    public override void ExecuteMechanic(PlayerMechanics playerMechanics)
    {
        if (i == 0)
        {
            originalSpeed = playerMechanics.player.maxSpeed;
            i++;
        }

        playerMechanics.player.maxSpeed *= (1 + (espressoValue / 1000.0f));
    }
Exemplo n.º 11
0
 /// <summary>
 ///  Define the overrideable ExecuteMechanic. Play the coffeeBomb particle effect if it isnt null.
 ///  Afterwards, let AI lose the focus of the player and teleport the player towards the closet checkpoint/spawnpoint.
 /// </summary>
 /// <param name="playerMechanics"></param>
 public override void ExecuteMechanic(PlayerMechanics playerMechanics)
 {
     if (i == 0)
     {
         playerMechanics.player.caught = true;
         iBomb = Instantiate(coffeeBombParticle, playerMechanics.player.transform.position, Quaternion.identity, null);
         if (iBomb && !iBomb.activeInHierarchy)
         {
             iBomb.SetActive(true);
         }
         i++;
     }
 }
Exemplo n.º 12
0
 private void OnTriggerExit2D(Collider2D collider)
 {
     if (collider.tag == "tag_player")
     {
         promptPickUp = false;
         //Set the player to null only of the object is not picked up
         if (!pickedUp && collider.gameObject.GetComponent <PlayerMechanics>().itemPickedUp == null)
         {
             VirtualJoystick.pickUpButton.SetActive(false);
             playerMechanics = null;
         }
     }
 }
Exemplo n.º 13
0
    protected override void Awake()
    {
        base.Awake();

        inv = GetComponent <Inventory>();

        input       = new InputController(sensitivity);
        controller  = new PlayerController(input, GetComponent <Rigidbody>(), GetComponent <GravityObject>(), GetComponent <Animator>(), GetComponent <Collider>());
        cam         = new PlayerCamera(input, transform, cameraOffset);
        inventory   = new PlayerInventory(input, cam, GetComponentInChildren <InvArm>());
        interaction = new PlayerInteraction(this, input, cam, inv);
        mechanics   = new PlayerMechanics(this, input, interaction, toolbar);
        codex       = new Codex(codexParent);
    }
Exemplo n.º 14
0
 protected override void OnTriggerEnter(Collider collision)
 {
     if (collision.transform.tag == "Player")
     {
         if (collision.transform.GetComponent <PlayerBehavior>().breakRock)
         {
             this.Die();
             PlayerMechanics.Move(collision.transform.GetComponent <PlayerBehavior>());
         }
         else
         {
             collision.transform.GetComponent <PlayerBehavior>().Die();
         }
     }
 }
Exemplo n.º 15
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.tag == "tag_player")
        {
            promptPickUp    = true;
            playerMechanics = collider.gameObject.GetComponent <PlayerMechanics>();

            //Enable the button on the controls canvas
            VirtualJoystick.pickUpButton.SetActive(true);
            //Set the sprite to pick up sprite
            if (playerMechanics.itemPickedUp == null)
            {
                VirtualJoystick.pickUpButton.GetComponent <UnityEngine.UI.Image>().sprite = VirtualJoystick.pickUpButton.GetComponent <PickUpButton>().pickupSprite;
            }
        }
    }
Exemplo n.º 16
0
 public void TakeDamage(PlayerMechanics whoShooted, int amount)
 {
     if (isServer)
     {
         health -= amount;
         if (health <= 0)
         {
             health = 100;
             Debug.LogError($"Server before die {this.hasAuthority}");
             RpcDie();
             death = true;
             NetworkIdentity identity = GetComponent <NetworkIdentity>();
             //TargetRespawn(identity.connectionToClient);
             Debug.LogError($"Server after die {this.hasAuthority}");
         }
     }
 }
Exemplo n.º 17
0
    public void InitGame()
    {
//		this.gameUI = GameObject.Find("GameUI").GetComponent<GameUIManager>();

        playerMechanics = gm.GetPlayerMechanics();
        enemyMechanics  = gm.GetEnemyMechanics();

        gm.HideInstructionUI();

        if (SceneManager.GetActiveScene().name == "GameNewPhase")
        {
            StartCoolDownTimer(3);
        }
        else
        {
            StartCoolDownTimer(8);
        }
    }
Exemplo n.º 18
0
    void OnTriggerEnter2D(Collider2D hitinfo)
    {
        Enemy1 enemy = hitinfo.GetComponent <Enemy1>();

        if (enemy != null)
        {
            enemy.TakeDamge(damage);
            enemy.Feedback();
        }
        PlayerMechanics player = hitinfo.GetComponent <PlayerMechanics>();

        if (player != null)
        {
            player.TakeDamge(damage);
        }
        Instantiate(BulletEx, transform.position, quaternion.identity);
        Destroy(gameObject);
    }
Exemplo n.º 19
0
        public void Setup(PlayerMechanics playerMechs, Character c, GrabAnimationInfo animInfo)
        {
            stageOneEntered = true;
            playerMechanics = playerMechs;
            this.player     = playerMechs.player;
            animator        = playerMechanics.player.playerSprite.GetComponent <Animator>();
            this.c          = c;

            Debug.Log("animator set: " + animator.name);

            if (animInfo.grabStartAnimationClip != null)
            {
                grabanimationHash = animInfo.grabStartAnimationClip.GetHashCode();
                grabClip          = animInfo.grabStartAnimationClip;
            }

            //Once the conditions are met, this block is executed only once. So, the absorb has to be set here
            animator.SetBool("Absorb", true);
        }
Exemplo n.º 20
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (!changeMovement)
        {
            PlayerMechanics.Move(this);
        }

        if (InputManager.Toched() && canTap)
        {
            canTap = false;
            onTap(this);
            StartCoroutine(TapCooldown(tapCooldown));
        }
        if (InputManager.Drag().x > 0 && canDrag)
        {
            canDrag = false;
            onDrag(this);
            StartCoroutine(DragCooldown(dragCooldown));
        }
    }
Exemplo n.º 21
0
    public override void Activate(PlayerMechanics player)
    {
        RocketProjectile copy = Instantiate(RocketProjectile, player.transform.position, Quaternion.identity, SkillParent);

        Vector2 direction;

        if (Input.GetKey(KeyCode.W))
        {
            if (Input.GetKey(KeyCode.A))
            {
                direction = new Vector2(-1, 1);
                copy.transform.eulerAngles = new Vector3(0, 0, 45);
            }
            else if (Input.GetKey(KeyCode.D))
            {
                direction = new Vector2(1, 1);
                copy.transform.eulerAngles = new Vector3(0, 0, -45);
            }
            else
            {
                direction = new Vector2(0, 1);
            }
        }
        else if (Input.GetKey(KeyCode.A))
        {
            direction = new Vector2(-1, 0);
            copy.transform.eulerAngles = new Vector3(0, 0, 90);
        }
        else if (Input.GetKey(KeyCode.D))
        {
            direction = new Vector2(1, 0);
            copy.transform.eulerAngles = new Vector3(0, 0, -90);
        }
        else
        {
            direction = new Vector2(0, 1);
        }

        copy.SetDirection(direction);
    }
Exemplo n.º 22
0
        private void Update()
        {
            if (client.LocalPlayer == null)
            {
                return;
            }

            if (!client.LocalPlayer.PlayerObject)
            {
                return;
            }

            if (!mechanics)
            {
                mechanics = client.LocalPlayer.PlayerObject.GetComponent <PlayerMechanics>();
            }

            if (mechanics.Health.ToString() != healthText.text.ToString())
            {
                SetHealth(mechanics.Health);
            }
        }
Exemplo n.º 23
0
    public override void Activate(PlayerMechanics player)
    {
        Rope rope = Instantiate(this, player.transform.position, Quaternion.identity);

        rope.Begin();
    }
Exemplo n.º 24
0
 /// <summary>
 ///  Define the overrideable CleanUpMechanic. Reset the setup for the mechanic.
 /// </summary>
 /// <param name="playerMechanics"></param>
 public override void CleanUpMechanic(PlayerMechanics playerMechanics)
 {
     i = 0;
 }
Exemplo n.º 25
0
 /// <summary>
 ///  Define the overrideable ExecuteMechanic.
 /// </summary>
 /// <param name="playerMechanics"></param>
 public override void ExecuteMechanic(PlayerMechanics playerMechanics)
 {
     Spawn(playerMechanics);
 }
Exemplo n.º 26
0
 public abstract void Activate(PlayerMechanics player);
Exemplo n.º 27
0
 private void Awake()
 {
     gm = GetComponent <GameManagement>();
     playerMechanics = gm.GetPlayerMechanics();
     enemyMechanics  = gm.GetEnemyMechanics();
 }
Exemplo n.º 28
0
 /// <summary>
 /// Declare an overrideable method for cleaning up all mechanics.
 /// </summary>
 /// <param name="playerMechanics"></param>
 public abstract void CleanUpMechanic(PlayerMechanics playerMechanics);
Exemplo n.º 29
0
 /// <summary>
 /// Declare an overrideable method for executing all mechanics.
 /// </summary>
 /// <param name="playerMechanics"></param>
 public abstract void ExecuteMechanic(PlayerMechanics playerMechanics);
Exemplo n.º 30
0
 public static void SaveInfo(PlayerMechanics player)
 {
     PlayerPrefs.SetFloat("x", player.transform.position.x);
     PlayerPrefs.SetFloat("y", player.transform.position.y);
     PlayerPrefs.SetFloat("z", player.transform.position.z);
 }