示例#1
0
    public void Update(float deltaTime, PlayerInputScript player)
    {
        AttackTimer += deltaTime;
        player.UpdateAttackInputVariables(AttackTimer >= blockAttackInputTime, AttackTimer > -blockNewAttackTime);
        if (!hasDamaged && AttackTimer >= damageTime)
        {
            Collider2D[] hits = player.ThrowAttack(attackPosition, attackSize);
            foreach (Collider2D hit in hits)
            {
                HealthComponent healthComponent = hit.GetComponent <HealthComponent>();
                if (healthComponent != null)
                {
                    healthComponent.Damage(damage, Vector2.zero);
                }
                EnemyHand enemyHand = hit.GetComponent <EnemyHand>();
                if (enemyHand != null)
                {
                    //Debug.Log("Test");
                    enemyHand.Damage(damage);
                }
            }
            hasDamaged = true;
        }

        if (AttackTimer >= attackLength)
        {
            player.EndAttack();
        }
    }
    public virtual void doAction(InteractionType interaction)
    {
        switch (interaction)
        {
        case InteractionType.Examine:
            //player.GetComponent<PlayerInputScript>().enableExamineObjectText(data.examineText);
            GameManagerScript.gameManager.conversationUI.GetComponent <ConversationScript>().examineActor(data, true);
            break;

        case InteractionType.Use:
            Debug.Log("Object Used");
            break;

        case InteractionType.PickUp:
            PlayerInputScript playerScript = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInputScript>();
            playerScript.stopHighlightingWorldObject(this);
            GetComponent <PickUpObjectScript>().addItemToInventory();
            break;

        case InteractionType.GoTo:
            GetComponent <GoToNewAreaTriggerScript>().goToNewArea();
            break;

        case InteractionType.Separate:
            GameManagerScript.gameManager.separateActor(this);
            break;
        }
    }
示例#3
0
    public bool isDodge;  // trapType2FireAttack을 피하기 위한것
    #endregion


    private void Start()
    {
        if (SceneManager.GetActiveScene().name == "Tutorial_Scene_Ver2")
        {
            tutorialManagerVer2Script = GameObject.Find("TutorialManagerVer2").GetComponent <TutorialManagerVer2>();
        }

        playerColliderConScript = GetComponent <PlayerColliderCon>();
        rectTransform           = GetComponent <RectTransform>();
        rigid           = GetComponent <Rigidbody>();
        dodgeConScript  = GetComponent <PlayerDodgeCon>();
        animationScript = GetComponent <PlayerAniScript>();
        attackConScript = GetComponent <PlayerAttackCon>();
        spConScript     = GetComponent <PlayerSpCon>();
        cam             = FindObjectOfType <Camera>();

        isDodge = false;
        hP      = maxHP;

        playerHitted  = PlayerHitted.none;
        playerUIState = PlayerUI.invenOff;
        state         = PlayerState.idle;
        mousePlace    = MousePlace.top;

        instance = this;
        if (null == instance)
        {
            instance = this;
        }
    }
示例#4
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
示例#5
0
 void Start()
 {
     anim = GetComponentInChildren<Animator>();
     cam = Camera.main;
     rigibody = GetComponent<Rigidbody>();
     playerInput = GetComponent<PlayerInputScript>();
 }
 /**
  * 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");
     }
 }
 public PlayerStateMoveToNewLedge(PlayerInputScript player, GameObject go)
 {
     ledge         = go;
     pi            = player;
     startPosition = player.GetPlayerTransform().position;
     startTime     = Time.time;
 }
示例#8
0
 public PlayerStateJumping(PlayerInputScript player)
 {
     pi = player;
     pi.DecrementJumpCount();
     startPosition = pi.GetPlayerTransform().position;
     startTime     = Time.time;
 }
示例#9
0
 private void Start()
 {
     spConScript    = GetComponent <PlayerSpCon>();
     aniConScript   = GetComponent <PlayerAniScript>();
     dodgeConScript = GetComponent <PlayerDodgeCon>();
     inputScript    = GetComponent <PlayerInputScript>();
 }
示例#10
0
 // USE THIS METHOD to access this object. (as in, MenuScript.instance().whatever())
 public static PlayerInputScript instance()
 {
     if (instance_ == null)
     {
         instance_ = GameObject.FindObjectOfType <PlayerInputScript> ();
     }
     return(instance_);
 }
示例#11
0
 public PlayerStateDash(PlayerInputScript player)
 {
     pi            = player;
     startPosition = pi.GetPlayerTransform().position;
     endPosition   = startPosition + pi.GetPlayerTransform().forward *dashLength;
     startTime     = Time.time;
     pi.gameObject.GetComponent <Rigidbody>().useGravity = false;
 }
示例#12
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        PlayerInputScript PIS = collision.collider.GetComponent <PlayerInputScript>();

        if (PIS != null && attacking)
        {
            PIS.Damage(1);
        }
    }
示例#13
0
    private void GetComponents()
    {
        PlayerInputScript    = GetComponent <PlayerInputScript>();
        PlayerMovementScript = GetComponent <PlayerMovementScript>();

        Animator       = GetComponent <Animator>();
        SpriteRenderer = GetComponent <SpriteRenderer>();
        Rb2d           = GetComponent <Rigidbody2D>();
    }
示例#14
0
 void Start()
 {
     mesh = new Mesh();
     GetComponent <MeshFilter>().mesh = mesh;
     CreateShape();
     UpdateMesh();
     transform.position = player.transform.position;
     inputScript        = player.GetComponent <PlayerInputScript>();
 }
示例#15
0
    public void fadeOutBackground()
    {
        PlayerInputScript player = FindObjectOfType <PlayerInputScript>();

        player.setHighlightedInventoryItemToNull();
        player.setHighlightedWorldObjectToNull();
        fadeOutImage_exclUI.enabled = true;
        fadeOutImage_exclUI.color   = new Color(fadeOutImageColour.r, fadeOutImageColour.g, fadeOutImageColour.b, 0.5f);
    }
示例#16
0
    private void Start()
    {
        forTutorialMonsterCheckOnce = false;

        isCool   = false;
        isSucess = false;

        inputScript       = GetComponent <PlayerInputScript>();
        playerSpConScript = GetComponent <PlayerSpCon>();
    }
示例#17
0
 public PlayerStateAim(PlayerInputScript player)
 {
     pi = player;
     pi.playerScript.EnableWeaponScript();
     pi.playerScript.GetCurrentCamera().GetComponent <OverShoulderCameraController>().enabled = true;
     pi.playerScript.GetCurrentCamera().GetComponent <ThirdPersonCameraController>().EnableReticle();
     pi.playerScript.GetCurrentCamera().GetComponent <ThirdPersonCameraController>().enabled = false;
     pi.playerScript.GetCurrentCamera().GetComponent <OverShoulderCameraController>().AttachToPlayer();
     Debug.Log("Entering aim state");
 }
示例#18
0
    public PlayerStateFalling(PlayerInputScript player)
    {
        fallingVelocity = -2f;
        pi             = player;
        superJumpReady = false;
        Debug.Log("entering falling state");
        Thread thread = new Thread(() => {
            Thread.Sleep(150);
            fallingVelocity = -8f;
        });

        thread.Start();
    }
示例#19
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;
 }
    private void OnTriggerStay(Collider other)
    {
        Debug.Log("object collision");
        player = GameObject.FindGameObjectWithTag("Player");

        if (other.gameObject.Equals(player))
        {
            Debug.Log("Player collision");
            PlayerInputScript playerScript = player.GetComponent <PlayerInputScript>();
            if (playerScript.isAnActionQueued())
            {
                Debug.Log("Action queued");
                GameObject queuedObject = playerScript.getQueuedActionObject();
                if (queuedObject.Equals(transform.parent.gameObject))
                {
                    playerScript.stopMovement();
                    // TODO: make player look at parent object
                    InteractableObjectScript.InteractionType interaction = playerScript.getQueuedActionType();
                    playerScript.setQueuedAction(null, InteractableObjectScript.InteractionType.Examine); // reset queued action to stop this function running indefinitely

                    if (interaction == InteractableObjectScript.InteractionType.Combine)
                    {
                        if (!GameManagerScript.gameManager.combineActors(playerScript.combiningItem, transform.parent.GetComponent <InteractableObjectScript>()))
                        {
                            GameManagerScript.gameManager.conversationUI.GetComponent <ConversationScript>().showConversation(GameManagerScript.gameManager.failedItemCombinationConversationData);
                            //player.GetComponent<PlayerInputScript>().enableExamineObjectText("I can't combine those...");
                        }
                    }
                    else if (interaction == InteractableObjectScript.InteractionType.GoTo)
                    {
                        LeaveSceneScript leaveSceneScript = queuedObject.GetComponent <LeaveSceneScript>();
                        if (leaveSceneScript.adjacentSceneName == "map_screen")
                        {
                            GameManagerScript.gameManager.openMapScreen();
                        }
                        else
                        {
                            GameManagerScript.gameManager.fadeAndLoadScene(leaveSceneScript.adjacentSceneName);
                        }
                    }
                    else
                    {
                        objectScript.doAction(interaction);
                    }
                }
            }
        }
    }
    public PlayerStateHangingOnLedge(PlayerInputScript player, GameObject go)
    {
        pi    = player;
        ledge = go;
        //Ensure that the player is rotated facing the ledge
        Quaternion r = ledge.GetComponent <LedgeScript>().GetRotation();
        Transform  t = pi.playerScript.GetPlayerTransform();

        t.eulerAngles = new Vector3(t.eulerAngles.x, r.eulerAngles.y - 90, t.eulerAngles.z);
        //Turn off gravity so that the player doesn't fall
        pi.gameObject.GetComponent <Rigidbody>().useGravity = false;
        Debug.Log("Hanging on ledge state");
        //Freeze the player so that they don't rotate or move while hanging on the ledge
        pi.GetRigidbody().constraints = pi.GetFreezeAll();
        //Player cannot jump until they stop pressing the jump input
        canJump = false;
    }
示例#22
0
    // Update is called once per frame

    void Update()
    {
        CheckPlayerInput();
        currentTile = PlayerInputScript.instance().GetCurrentTile();

        //If the player is allowed to build
        if (buildButtonA && currentTile != null)
        {
            //If build-button is pressed

            if (Shop.PurchaseMachine())
            {
                if (currentTile.transform.position.y > 6)
                {
                    buildingRotation.SetLookRotation(new Vector3(0f, 0f, 180f), Vector3.down);
                }
                else
                {
                    buildingRotation.SetLookRotation(new Vector3(0f, 0f, 0f), Vector3.up);
                }

                BuildOnTile(0);
            }
        }
        else if (buildButtonB && currentTile != null)
        {
            //If build-button is pressed

            if (Shop.PurchaseRedTurret())
            {
                if (currentTile.transform.position.y > 6)
                {
                    buildingRotation.SetLookRotation(new Vector3(0f, 0f, 180f), Vector3.down);
                }
                else
                {
                    buildingRotation.SetLookRotation(new Vector3(0f, 0f, 0f), Vector3.up);
                }

                BuildOnTile(1);
            }
        }
    }
示例#23
0
    private void Start()
    {
        playerSpConScript       = GetComponent <PlayerSpCon>();
        inputScript             = GetComponent <PlayerInputScript>();
        playerAnimationScript   = GetComponent <PlayerAniScript>();
        playerParticleConScript = GetComponent <PlayerParticleCon>();

        WeaponStateEnum = WeaponState.normalSword;


        for (int i = 0; i < 3; i++)
        {
            playerSwordBoxCollider[i].enabled = false;
        }

        onceCheck[2] = false;
        onceCheck[3] = false;

        isCool = false;
    }
示例#24
0
    void Start()
    {
        line   = GetComponent <LineRenderer>();
        mat    = GetComponentInChildren <SpriteRenderer>().material;
        sprite = GetComponentInChildren <SpriteRenderer>();
        input  = GetComponent <PlayerInputScript>();

        BoxCollider2D collider = GetComponent <BoxCollider2D>();

        halfWidth = collider.size.x / 2;
        height    = collider.size.y;

        walls = new Plane[] {
            new Plane(Vector2.up, Vector2.down * frameDist),
            new Plane(Vector2.right, Vector2.left * frameDist),
            new Plane(Vector2.down, Vector2.up * frameDist),
            new Plane(Vector2.left, Vector2.right * frameDist),
        };

        line.material.SetColor("_EmissionColor", glowColor);
    }
示例#25
0
    private IEnumerator fadeAndSwitchScene(string sceneName)
    {
        PlayerInputScript player = FindObjectOfType <PlayerInputScript>();

        player.setHighlightedInventoryItemToNull();
        player.setHighlightedWorldObjectToNull();

        yield return(StartCoroutine(fade(1f)));

        closeMapScreen();

        BeforeSceneUnload?.Invoke(); // calls all functions that are 'subscibed' to the BeforeSceneUnload function

        yield return(SceneManager.UnloadSceneAsync(SceneManager.GetActiveScene().buildIndex));

        yield return(StartCoroutine(loadSceneAndSetActive(sceneName)));

        AfterSceneLoad?.Invoke();

        yield return(StartCoroutine(fade(0f)));
    }
示例#26
0
 public void HandleWeaponSwapInput(PlayerInputScript pi)
 {
     nextWeaponInput = pi.GetNextWeaponInput();
     prevWeaponInput = pi.GetPrevWeaponInput();
     if (nextWeaponInput == 0f)
     {
         canSwapNext = true;
     }
     if (prevWeaponInput == 0f)
     {
         canSwapPrev = true;
     }
     if (nextWeaponInput > 0f && canSwapNext)
     {
         canSwapNext = false;
         Debug.Log("Calling playerscript to ask the weapon script to swap to the next!");
     }
     else if (prevWeaponInput > 0f && canSwapPrev)
     {
         canSwapPrev = false;
         Debug.Log("Calling playerscript to ask the weapon script to swap to the prev!");
     }
 }
    public PlayerStateClimbing(PlayerInputScript player, GameObject go)
    {
        pi            = player;
        startPosition = pi.GetPlayerTransform().position;
        startTime     = Time.time;
        ledge         = go;

        //If this is the end of the ledge, and there's no ledge to jump onto, then don't climb
        if (startPosition == endPosition)
        {
            pi.currentState = new PlayerStateHangingOnLedge(pi, ledge);
        }

        mi = pi.GetMovementInput();
        if (mi.x >= 0.2f)
        {
            endPosition = ledge.GetComponent <LedgeScript>().GetRightMostPoint();
        }
        if (mi.x <= -0.2f)
        {
            endPosition = ledge.GetComponent <LedgeScript>().GetLeftMostPoint();
        }
        Debug.Log("entering climbing");
    }
示例#28
0
文件: LiftScript.cs 项目: Gotyn/WHICH
 void Start()
 {
     small = GameManagerScript.SB;
     rigibody = liftable.GetComponent<Rigidbody> ();
     smallInput = GameManagerScript.SB.GetComponent<PlayerInputScript>();
     glow = GetComponentInChildren<ParticleSystem> ();
     Glow(false);
     endpos = endPosition.position;
     animator = smallInput.GetComponentInChildren<Animator>();
     liftSound = GetComponent<AudioSource> ();
 }
示例#29
0
 void Awake()
 {
     startColor = PlayerInputScript.instance().GetStartColor();
     LayoutBoard(usableBoardPiece, unusableBoardPiece);
 }
示例#30
0
 /*The constructor takes in the player input script because it needs
  * to be able to communicate with the player and accept data about the
  * player, like input etc*/
 public PlayerStateIdle(PlayerInputScript player)
 {
     pi = player;
     pi.ResetJumpCount();
     Debug.Log("Entering idle state");
 }
示例#31
0
 public PlayerStateDeath(PlayerInputScript player)
 {
     pi = player;
 }
示例#32
0
文件: HolderTest.cs 项目: Gotyn/WHICH
 void Start()
 {
     bigBroMovement = GetComponentInParent<PlayerMovement>();
     bigInput = GetComponentInParent<PlayerInputScript>();
     rigidBody = GetComponentInParent<Rigidbody>();
     smallBroAnimator = GameManagerScript.SB.GetComponentInChildren<Animator>();
     mageGlow.enableEmission = false;
     mageGlowGreen.enableEmission = false;
 }
 public PlayerStateWalking(PlayerInputScript player)
 {
     pi = player;
     Debug.Log("Entering walking state");
 }
示例#34
0
 public void RegisterInputScript(PlayerInputScript input)
 {
     currentPlayer = input;
 }
示例#35
0
    void Awake()
    {
        base.Awake();

        playerInput = GetComponent<PlayerInputScript>();	//Get reference to PlayerInputScript component
        spawningEffect = Resources.Load("Prefabs/PorterEffect") as GameObject;

        spawningEffect = Resources.Load("Prefabs/portalEffect") as GameObject;

        if (currentHat)
            hatType = currentHat.hatType;
    }
示例#36
0
    void Start()
    {
        menu = MenuScript.Instance;
        chat = GameObject.Find("Chat").GetComponent<Canvas>();
        text =  chat.GetComponentInChildren<Text>();
        dialogImage = chat.GetComponentInChildren<Image>();

        journalScript = GetComponent<JournalScript>();
        smallInput = GameManagerScript.SB.GetComponent<PlayerInputScript>();
        bigInput = GameManagerScript.BB.GetComponent<PlayerInputScript>();

        chat.enabled = false;
    }