Esempio n. 1
0
    public override bool PotionEffectStart(FPSMovement playerMovement)
    {
        //Awful hack for last minute fixes
        ABILITY_FLAG flag = CharacterState.GetFlagFromString(effect);
        bool         AbillityActive;

        if (flag == ABILITY_FLAG.LEVITATE)
        {
            AbillityActive = (CharacterState.IsAbilityFlagActive(ABILITY_FLAG.LEVITATE) || CharacterState.IsAbilityFlagActive(ABILITY_FLAG.SLOWFALL));
        }
        else if (flag == ABILITY_FLAG.TELEPORT)
        {
            //If the player may not Teleport from outside factors, it should be treated as if the potion is on at this stage - Shitty hack fix
            AbillityActive = (!playerMovement.MayTeleport || CharacterState.IsAbilityFlagActive(flag));
        }
        else
        {
            AbillityActive = CharacterState.IsAbilityFlagActive(flag);
        }


        if (!AbillityActive)
        {
            CharacterState.AddAbilityFlag(effect, duration);
            AddAdditionalEffects();
            return(true);
        }
        return(false);
    }
Esempio n. 2
0
    public string character;                // USED TO STORE WHAT CHARACTER WAS LAST USING THE DIALOGUE SYSTEM

    public Save_Data(FPSMovement player)    // THIS IS A CONSTRUCTOR THAT GETS CALLED WHEN THE SAVE BUTTON IS PRESSED
    {
        savePlayersLocationInWorld(player); // CALLS THE SAVEPLAYERLOCATIONINWORLD WHICH SAVES THE PLAYERS CURRENT POSITION AND ROTATION
        saveLevel();                        // CALLS THE SAVELEVEL METHOD WHICH SAVES WHAT LEVEL THE PLAYER IS CURRENTLY ON
        saveDateAndTime();                  // CALLS THE SAVEDATEANDTIME METHOD WHICH SAVES THE DATE AND TIME OF WHEN THE GAME WAS LAST SAVED
        saveCurrentDialogueIndex();         // CALLS THE SAVECURRENTDIALOGUETEXT METHOD TO SAVE HOW FAR THROUGH THE DIALOGUE THE PLAYER IS
    }
Esempio n. 3
0
    private static string path = Application.persistentDataPath + "/save1.json"; // THIS IS THE SAVE LOCATION AND NAME OF THE SAVE FILE

    public static void saveGameToJson(FPSMovement player)
    {
        Save_Data data = new Save_Data(player);             // CREATES A NEW PLAYER_DATA INSTANCE PASSING IN THE PLAYER VARIABLE

        string dataAsJson = JsonUtility.ToJson(data, true); // THIS CREATES A NEW STRING CALLED DATAASJSON AND CONVERTS THE PLAYER_DATA WITH PRETTY PRINT ENABLED

        File.WriteAllText(path, dataAsJson);                // THIS THEN WRITES THE CONVERTED DATA TO THE PREVIOUSLY CREATED JSON FILE
    }
Esempio n. 4
0
 public void Update(FPSMovement movement)
 {
     // Change to walk state.
     if (MyInput.GetButtonUp("Sprint"))
     {
         movement.ChangeState(new FPSCharacterStateWalk());
     }
 }
 public void Update(FPSMovement movement)
 {
     // Change to idle state.
     if (movement.m_target.isGrounded)
     {
         movement.ChangeState(new FPSCharacterStateIdle());
     }
 }
 public void Update(FPSMovement movement)
 {
     // Change to walk state.
     if (movement.GetVelocity() > FPSConstants.BEGIN_WALK_VELOCITY)
     {
         movement.ChangeState(new FPSCharacterStateWalk());
     }
 }
Esempio n. 7
0
    public bool Interact(Transform interactor)
    {
        if (_enabled && (isUnderwater == false || !FPSMovement.IsSwimming()))
        {
            if (FlowerLibrary.GetFlowerDiscoverAmount(_flowerData.itemName) == 0)
            {
                BookManager.SetPickedFlower(_flowerData);
                if (onPickUpEvent != null)
                {
                    onPickUpEvent.Invoke(" " + _flowerData.itemName, _flowerData.itemIcon);
                }
            }
            //Pickup save system
            PickUp();
            //NotificationObject.name = _flowerData.itemName; // For notification system(not needed anymore, but leave it?)
            //NotificationObject.sprite = _flowerData.itemIcon; // For notification system(not needed anymore, but leave it?)

            Play_PickupSound(_flowerData.itemName);
            FlowerLibrary.IncrementFlower(_flowerData.itemName, _flowersReturned);
            if (_gameobjectOverload.Length == 0)
            {
                if (_pickupAlpha != null)
                {
                    GetComponent <MeshRenderer>().material.SetTexture("_Alpha", _pickupAlpha);
                    GetComponent <Collider>().enabled = false; //This may not work since there are multiple colliders
                }
                else
                {
                    Destroy(this.gameObject);
                }
            }
            else
            {
                foreach (GameObject gObject in _gameobjectOverload)
                {
                    if (_pickupAlpha != null)
                    {
                        gObject.GetComponent <MeshRenderer>().material.SetTexture("_Alpha", _pickupAlpha);
                    }
                    else
                    {
                        Destroy(gObject);
                    }
                }
                GetComponent <Collider>().enabled = false;//This may not work since there are multiple colliders
            }
            StartCoroutine(ShakeFlower(interactor, _pickupAnimationTime, _pickupAnimationForce));
            _pickupAction.Invoke();
            AlchemyOrganizer_2.DiscoverRecipes(_flowerData);
            if (_dissableTriggerafterPickup)
            {
                GetComponent <Collider>().enabled = false;
            }
            return(true); //Doesn't really have a purpose for this
        }
        return(false);
    }
Esempio n. 8
0
    public void StartState(FPSMovement movement)
    {
        GunController activeGun = GameStats._GunsManager.GetActiveGun();
        Crosshair     crosshair = activeGun._Crosshair;

        if (crosshair != null)
        {
            crosshair.ChangeInaccuracy(0.5f);
        }
    }
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
        m_UIProperties = GameStats._UICharacterProperties;
        m_hurtEffect   = GameStats._GetHurtEffect;
        m_fpsMovement  = GameStats._FPSMovement;
        m_audioSource  = GetComponent <AudioSource> ();
        m_health       = m_maxHealth;

        IsDead = false;
    }
Esempio n. 10
0
    private void AquireReferences()
    {
        kb       = GetComponent <FPSKinematicBody>();
        look     = GetComponent <FPSLook>();
        movement = GetComponent <FPSMovement>();

        cameraTransform = transform.GetChild(0);
        cameraComponent = cameraTransform.GetChild(0).GetComponent <Camera>();
        seekerTransform = GameObject.Find("seeker").transform;
        seekerTransform.gameObject.SetActive(false);
    }
    public void Update(FPSMovement movement)
    {
        m_currPlayingDie = movement.m_cameraAnimator.GetCurrentAnimatorStateInfo(0).IsName("CameraDie");

        if (m_prevPlayingDie && !m_currPlayingDie)
        {
            GameStats._MenuButtonsHandler.OnEndGame();
        }

        m_prevPlayingDie = m_currPlayingDie;
    }
Esempio n. 12
0
    private void savePlayersLocationInWorld(FPSMovement player)
    {
        position = new float[3];                      // INSTANTIATES THE POSITION FLOAT ALLOCATING 3 VALUES
        rotation = new float[3];                      // INSTANTIATES THE ROTATION FLOAT ALLOCATING 1 VALUE

        position[0] = player.transform.position.x;    // SETS THE FIRST ARRAY INDEX TO THE PLAYERS X POSITION
        position[1] = player.transform.position.y;    // SETS THE SECOND ARRAY INDEX TO THE PLAYERS Y POSITION
        position[2] = player.transform.position.z;    // SETS THE THIRD ARRAY INDEX TO THE PLAYERS Z POSITION

        rotation[0] = player.transform.eulerAngles.x; // SETS THE FIRST ARRAY INDEX TO THE PLAYERS X ROTATION
        rotation[1] = player.transform.eulerAngles.y; // SETS THE FIRST ARRAY INDEX TO THE PLAYERS Y ROTATION
        rotation[2] = player.transform.eulerAngles.z; // SETS THE FIRST ARRAY INDEX TO THE PLAYERS Z ROTATION
    }
Esempio n. 13
0
    public void Update(FPSMovement movement)
    {
        // Change to idle state.
        if (movement.GetVelocity() < FPSConstants.BEGIN_WALK_VELOCITY)
        {
            movement.ChangeState(new FPSCharacterStateIdle());
        }

        // Change to run state.
        if (MyInput.GetButtonDown("Sprint"))
        {
            movement.ChangeState(new FPSCharacterStateRun());
        }
    }
    public void StartState(FPSMovement movement)
    {
        // Raise character to height.
        movement.MoveDirection = new Vector3(movement.MoveDirection.x, movement.m_jumpHeight, movement.MoveDirection.z);

        // Hide crosshair when character is jumping.
        GunController activeGun = GameStats._GunsManager.GetActiveGun();
        Crosshair     crosshair = activeGun._Crosshair;

        if (crosshair != null)
        {
            crosshair.gameObject.SetActive(false);
        }
    }
    public void EndState(FPSMovement movement)
    {
        // Show crosshair when character land.
        GunController activeGun = GameStats._GunsManager.GetActiveGun();
        Crosshair     crosshair = activeGun._Crosshair;

        if (crosshair != null)
        {
            crosshair.gameObject.SetActive(true);
        }

        // Play end animation.
        movement.m_cameraAnimator.SetTrigger("Land");
    }
Esempio n. 16
0
    void Start()
    {
        _camera = Camera.main;
        if (transform.GetComponentInParent <FPSMovement>() != null)
        {
            fpsMove = transform.GetComponentInParent <FPSMovement>();
        }
        //if(!networkView.isMine)
        //enabled = false;

        // Make the rigid body not change rotation
        //if (rigidbody)
        //rigidbody.freezeRotation = true;
    }
Esempio n. 17
0
    public override bool PotionEffectStart(FPSMovement p)
    {
        switch (type)
        {
        case CharacterStatType.Jump:
            if (!p._jumpForce.GetStatModifiers().Exists(x => x.Source == this))
            {
                potionEffect = new StatModifier(flat, StatType.Flat, this);
                p._jumpForce.AddModifier(potionEffect, duration);
                p._jumpForce.AddModifier(new StatModifier(factor, StatType.PercentMult, this), duration);
                return(true);
            }
            break;

        case CharacterStatType.Gravity:
            if (!p._gravity.GetStatModifiers().Exists(x => x.Source == this))
            {
                potionEffect = new StatModifier(flat, StatType.Flat, this);
                p._gravity.AddModifier(potionEffect, duration);
                // p._gravity.AddModifier(new StatModifier(factor, StatType.PercentMult, this), duration);
                return(true);
            }
            break;

        default:
            if (!(p._speed.GetStatModifiers().Exists(x => x.Source == this)))
            {
                potionEffect = new StatModifier(flat, StatType.Flat, this);
                p._speed.AddModifier(potionEffect, duration);
                p._speed.AddModifier(new StatModifier(factor, StatType.PercentMult, this), duration);

                EventParameter param = new EventParameter()
                {
                    intParam = -50, floatParam = 1
                };
                EventManager.TriggerEvent(EventNameLibrary.SPEED_INCREASE, param);
                param.intParam = 0;
                ActionDelayer.RunAfterDelay(() =>
                {
                    EventManager.TriggerEvent(EventNameLibrary.SPEED_INCREASE, param);
                }, duration);
                return(true);
            }
            break;
        }
        return(false);
    }
Esempio n. 18
0
    private void Start()
    {
        _movement                   = GetComponentInParent <FPSMovement>();
        event_P_Mov_Footsteps       = RuntimeManager.CreateInstance(player_Data.p_mov_rnd_footsteps);
        event_P_Mov_Swim            = RuntimeManager.CreateInstance(player_Data.p_mov_swim);
        event_P_Mov_Jump            = RuntimeManager.CreateInstance(player_Data.p_mov_jump);
        event_P_Mov_Land            = RuntimeManager.CreateInstance(player_Data.p_mov_land);
        event_P_Mov_EnterUnderwater = RuntimeManager.CreateInstance(player_Data.p_mov_enterUnderwater);

        event_Book_Close           = RuntimeManager.CreateInstance(player_Data.p_book_close);
        event_Book_Open            = RuntimeManager.CreateInstance(player_Data.p_book_open);
        event_Book_Page            = RuntimeManager.CreateInstance(player_Data.p_book_page);
        event_Book_Scribble        = RuntimeManager.CreateInstance(player_Data.p_book_scribble);
        event_Potion_Create        = RuntimeManager.CreateInstance(player_Data.p_potion_create);
        event_Potion_Teleportation = RuntimeManager.CreateInstance(player_Data.p_potion_teleport);
        event_Potion_Drink         = RuntimeManager.CreateInstance(player_Data.p_potion_drink);

        EventDescription groundMaterialEventDescription;

        event_P_Mov_Footsteps.getDescription(out groundMaterialEventDescription);
        PARAMETER_DESCRIPTION groundMaterialParameterDescription;

        groundMaterialEventDescription.getParameterDescriptionByName("ground_material", out groundMaterialParameterDescription);
        groundMaterialParameterId = groundMaterialParameterDescription.id;

        EventDescription underwaterEventDescription;

        event_P_Mov_Swim.getDescription(out underwaterEventDescription);
        PARAMETER_DESCRIPTION underwaterParameterDescription;

        underwaterEventDescription.getParameterDescriptionByName("underwater", out underwaterParameterDescription);
        underwaterParameterId = underwaterParameterDescription.id;

        EventDescription enterUnderwaterEventDescription;

        event_P_Mov_EnterUnderwater.getDescription(out enterUnderwaterEventDescription);
        PARAMETER_DESCRIPTION enterUnderwaterParameterDescription;

        enterUnderwaterEventDescription.getParameterDescriptionByName("enter", out enterUnderwaterParameterDescription);
        enterUnderwaterParameterId = enterUnderwaterParameterDescription.id;
    }
Esempio n. 19
0
 //abstract public void PotionEffectStart();
 abstract public bool PotionEffectStart(FPSMovement p);
Esempio n. 20
0
 public void EndState(FPSMovement movement)
 {
 }
Esempio n. 21
0
 // Use this for initialization
 void Start()
 {
     movement = GetComponent <FPSMovement>();
 }
Esempio n. 22
0
 public void SpeedPot(FPSMovement p)
 {
     //simpler code (preference)
     p._speed.AddModifier(new StatModifier(20, StatType.Flat, this), 3.0f);
     //p._speed.AddModifier(new StatModifier(0.3f, StatType.PercentMult, this));
 }
Esempio n. 23
0
 public void JumpPotEnd(FPSMovement p)
 {
     p._jumpForce.RemoveAllModifiers(this);
 }
Esempio n. 24
0
 // !OBS Weird bug causing script to disable itself when awake is used.
 void Awake()
 {
     playerMovement = this;
     _swimVelocity  = new Vector2(0f, 0f);
 }
Esempio n. 25
0
 public void GravityPotEnd(FPSMovement p)
 {
     p._gravity.RemoveAllModifiers(this);
 }
Esempio n. 26
0
 public void GravtityPot(FPSMovement p)
 {
     p._gravity.AddModifier(new StatModifier(10, StatType.Flat, this), 10.0f);
 }
Esempio n. 27
0
 private void Start()
 {
     movement    = GetComponent <FPSMovement>();
     groundCheck = GetComponent <FPSGroundCheck>();
     grapple     = GetComponent <Grapple>();
 }
Esempio n. 28
0
    void Update()
    {
        RaycastHit collision;
        bool       hit = Physics.Raycast(transform.position, transform.forward * distance, out collision, distance, _layerMask.value);

        Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * distance, Color.green, 1f);

        if (hit && transform.eulerAngles.x < 180)
        {
            //Debug.Log(collision.transform.name);
            PickupFlower[] pickupFlowers = collision.transform.GetComponents <PickupFlower>();

            if (FPSMovement.IsSwimming())
            {
                List <PickupFlower> notUnderwater = new List <PickupFlower>();
                for (int i = 0; i < pickupFlowers.Length; i++)
                {
                    if (!pickupFlowers[i].IsUnderwater())
                    {
                        notUnderwater.Add(pickupFlowers[i]);
                    }
                }
                if (notUnderwater.Count < 1)
                {
                    ChangeLookingCursor(false);
                    return;
                }
                else
                {
                    pickupFlowers = notUnderwater.ToArray();
                }
            }

            //Currently looking at an interactable
            bool lookingAtFlower = false;
            for (int i = 0; i < pickupFlowers.Length; i++)
            {
                if (pickupFlowers[i].SetEnabled)
                {
                    lookingAtFlower = true;
                    break;
                }
            }

            ChangeLookingCursor(lookingAtFlower);

            if (Input.GetButtonDown(InputKeyWords.ACTION_0))
            {
                IInteractable[] interactables = collision.transform.GetComponents <IInteractable>();
                Debug.Log(collision.transform.name);

                for (int i = 0; i < interactables.Length; i++)
                {
                    interactables[i].Interact(this.transform);
                }
            }
        }
        else
        {
            ChangeLookingCursor(false);
        }
    }
Esempio n. 29
0
 public void SpeedPotionEnd(FPSMovement p)
 {
     p._speed.RemoveAllModifiers(this);
 }
Esempio n. 30
0
 public void JumpPot(FPSMovement p)
 {
     p._jumpForce.AddModifier(new StatModifier(4, StatType.Flat, this), 10.0f);
 }