Example #1
0
    public override void Attack(int charge)
    {
        if (AnimationController == null)
        {
            AnimationController          = Player.GetComponent <PlayerAnimationController>();
            AnimationController.BBatAnim = this.GetComponent <Animator>();
        }

        AnimationController.PlayBBatAnimation();


        RaycastHit2D[] hits = Physics2D.RaycastAll(Player.transform.position, firePoint.right, attackRange, PlayerLayer);

        foreach (RaycastHit2D hit in hits)
        {
            PlayerHealth enemy = hit.transform.GetComponent <PlayerHealth>();

            if (enemy && enemy.gameObject != Player.gameObject)
            {
                enemy.CmdTakeDamage(damagePower, Player.gameObject);


                Vector3 direction = (firePoint.right + Vector3.up) * FlingIntensity;
                enemy.gameObject.GetComponent <PlayerManager>().CmdSetVelocity(direction.x, direction.y);
            }
        }
    }
Example #2
0
    void Start()
    {
        PlayerNetWorkData data = GameGlobalData.playerList[GameGlobalData.fd];
        float             posx = data.initPosition.x;
        float             posy = data.initPosition.y;
        int   row  = (int)Mathf.Abs(posy / GameConst.tileHeight);
        float posz = GameConst.staticLayers[row].position.z;

        transform.position = new Vector3(posx, posy, posz);
        behaviorCollector  = GetComponent <PlayerBehaviourCollector>();
        animatorController = GetComponent <PlayerAnimationController>();
        //GameGlobalData.player = this;
        movement          = GetComponent <PlayerMovement>();
        movement.speed    = data.speed;
        movement.maxSpeed = data.maxSpeed;
        bubbleCount       = data.bubbleCount;
        maxBubbleCount    = data.maxBubbleCount;
        power             = data.power;
        maxPower          = data.maxPower;
        boomTime          = data.boomTime;
        bubbles           = new List <Bubble>();
        startAccept       = false;
        colliderBox       = GetComponent <PlayerColliderBox>();
        //joystickDynamic = GameObject.Find("EasyTouchControlsCanvas/Joystick").GetComponent<ETCJoystick>();
        //joystickStatic = GameObject.Find("EasyTouchControlsCanvas/Joystick2").GetComponent<ETCJoystick>();
    }
Example #3
0
        public override void Init()
        {
            movementController    = GetComponent <PlayerMovementController>();
            actionController      = GetComponent <PlayerActionController>();
            rotationController    = GetComponent <PlayerRotationController>();
            animationController   = GetComponent <PlayerAnimationController>();
            inventoryController   = GetComponent <PlayerInventoryController>();
            weaponController      = GetComponent <PlayerWeaponController>();
            healthController      = GetComponent <HealthController>();
            reloadController      = GetComponent <PlayerReloadController>();
            interactionController = GetComponent <InteractionSearcherController>();
            executionController   = GetComponent <PlayerExecutionController>();
            limbsController       = GetComponentInChildren <LimbsController>();
            hitboxController      = GetComponentInChildren <HitboxController>();
            abilityController     = GetComponent <AbilityController>();

            tickPlayer.value = true;

            movementController.Init();
            actionController.Init();
            rotationController.Init();
            animationController.Init();
            weaponController.Init();
            inventoryController.Init();
            healthController.Init();
            reloadController.Init();
            interactionController.Init();
            executionController.Init();
            limbsController.Init();
            hitboxController.Init();
            abilityController.Init();
        }
Example #4
0
    private void Awake()
    {
        idleState   = new IdleState(this);
        moveState   = new MoveState(this);
        attackState = new AttackState(this);
        castState   = new CastState(this);
        fleeState   = new FleeState(this);
        defendState = new DefendState(this);

        anim            = GetComponent <Animator>();
        walkSpeed       = 1.0f;
        navMeshAgent    = GetComponent <NavMeshAgent>();
        navSpeedDefault = navMeshAgent.speed;

        eyes          = transform.FindChild("Eyes");
        sightCollider = GetComponent <SphereCollider>();
        tm            = GameObject.FindWithTag("TeamManager").GetComponent <TeamManager>();
        ah            = GameObject.FindWithTag("AbilityHelper").GetComponent <AbilityHelper>();

        //this is a mess. These are "shared" variables between co-op ai and player script
        player         = GetComponent <Player>();
        animController = player.animController;
        abilities      = player.abilities;
        attributes     = player.attributes;
        watchedEnemies = player.watchedEnemies;
        visibleEnemies = player.visibleEnemies;
    }
Example #5
0
    IEnumerator Shoot()
    {
        CancelInvoke("ResetHitCombo");
        isAttacking = true;
        PlayerAnimationController.SetBool("IsAttacking", true);

        weapon.sharedMesh = null;
        PlayerAnimationController.PlayAnimation("Shoot");

        yield return(new WaitForSeconds(PlayerAnimationController.AnimationClips["Shoot"].length * 0.6f / PlayerAnimationController.GetFloat("ShootSpeed")));

        Projectile projectile = Instantiate(projectilePrefab, projectileOrigin.position, Quaternion.identity);

        projectile.gameObject.SetActive(true);

        yield return(new WaitForSeconds(PlayerAnimationController.AnimationClips["Shoot"].length * 0.4f / PlayerAnimationController.GetFloat("ShootSpeed")));

        weapon.sharedMesh = defaultMesh;

        hitCombo = (hitCombo + 1) % 3;
        if (hitCombo != 0)
        {
            Invoke("ResetHitCombo", hitComboResetDelay);
        }

        PlayerAnimationController.SetBool("IsAttacking", false);

        yield return(new WaitForSeconds(ProjectileCooldown));

        isAttacking = false;
    }
Example #6
0
 void Awake()
 {
     _characterController = GetComponent <CharacterController>();
     _inputController     = GetComponent <IInputController>();
     _ledgeSensor         = GetComponent <LedgeSensor>();
     _animationController = GetComponent <PlayerAnimationController>();
 }
    /// <summary>
    /// 動物の生成
    /// </summary>
    void Generate()
    {
        for (int i = 0; i < laneArray.Length; ++i)
        {
            // 生成時間カウント
            laneArray[i].elapsedTime += Time.deltaTime;

            if (laneArray[i].elapsedTime > laneArray[i].nextGenerateTime)
            {
                int animalIndex = animalGenerateOrder[animalGeneratCurrentIndex];

                GameObject animalObject = Instantiate(animalData[animalIndex].animalPrefab, laneArray[i].generatePos, Quaternion.Euler(new Vector3(0, 90, 0)));
                animalObject.transform.parent = transform;
                PlayerAnimationController playerAnimationController = animalObject.GetComponent <PlayerAnimationController>();
                playerAnimationController.AnimationSwitch(PlayerAnimationController.AnimationType.Run);
                Animal animal = new Animal(animalObject, animalIndex);
                animalList.Add(animal);

                laneArray[i].elapsedTime      = 0.0f;
                laneArray[i].nextGenerateTime = animalData[animalIndex].nextTime;
                if (animalGeneratCurrentIndex < animalGenerateOrder.Length - 1)
                {
                    ++animalGeneratCurrentIndex;
                }
                else
                {
                    AnimalGeneratRandom();
                }
            }
        }
    }
Example #8
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Example #9
0
 /// <summary>
 /// Initializes variables
 /// </summary>
 void Start()
 {
     animCon = GetComponent <PlayerAnimationController>();
     sr      = GetComponent <SpriteRenderer>();
     invCon  = GetComponent <InventoryController>();
     colCon  = GetComponent <CollisionController>();
 }
Example #10
0
 public override void Init()
 {
     animController        = GetComponent <PlayerAnimationController>();
     attackInputAction     = Resources.Load("Input Actions/Input Action Attack") as ScriptableInputBoolAction;
     attackInputHeldAction = Resources.Load("Input Actions/Input Action Attack Held") as ScriptableInputBoolAction;
     isPlayerReloading     = Resources.Load("Player/PlayerIsReloading") as ScriptableBool;
 }
Example #11
0
    // Use this for initialization
    void Start()
    {
        rb             = GetComponent <Rigidbody2D>();
        movementVector = new Vector2(2f, 0);
        //movementVector.y *= 5; //gravity
        moveVec = new Vector2(0, 0);
        rb.collisionDetectionMode = CollisionDetectionMode2D.Continuous;
        rb.interpolation          = RigidbodyInterpolation2D.Extrapolate;

        energyLevel = 0;

        pAnim = GetComponent <PlayerAnimationController>();

        col = GetComponents <BoxCollider2D>();
        if (col[0].size.x > col[1].size.x)
        {
            topBox = col[0];
            botBox = col[1];
        }
        else
        {
            topBox = col[1];
            botBox = col[0];
        }
        collOffset = botBox.offset.y;
    }
Example #12
0
    private void Awake()
    {
        // get references
        playerController    = GetComponent <PlayerController>();
        animationController = GetComponent <PlayerAnimationController>();
        playerRigidbody     = GetComponent <Rigidbody2D>();


        // Create FSM States
        statesDictionary.Add(PlayerFSMState.Idle, new PlayerState_Idle(this, PlayerFSMState.Idle));
        statesDictionary.Add(PlayerFSMState.Running, new PlayerState_Running(this, PlayerFSMState.Running));
        statesDictionary.Add(PlayerFSMState.Jumping, new PlayerState_Jumping(this, PlayerFSMState.Jumping));
        statesDictionary.Add(PlayerFSMState.Crouched, new PlayerState_Crouched(this, PlayerFSMState.Crouched));
        statesDictionary.Add(PlayerFSMState.Climbing, new PlayerState_Climbing(this, PlayerFSMState.Climbing));
        statesDictionary.Add(PlayerFSMState.Hit, new PlayerState_Hit(this, PlayerFSMState.Hit));
        statesDictionary.Add(PlayerFSMState.Died, new PlayerState_Died(this, PlayerFSMState.Died));
        statesDictionary.Add(PlayerFSMState.FrogIdle, new PlayerState_FrogIdle(this, PlayerFSMState.FrogIdle));
        statesDictionary.Add(PlayerFSMState.FrogRunning, new PlayerState_FrogRunning(this, PlayerFSMState.FrogRunning));
        statesDictionary.Add(PlayerFSMState.FrogJumping, new PlayerState_FrogJumping(this, PlayerFSMState.FrogJumping));

        // assign initial state
        currentPlayerState = statesDictionary[PlayerFSMState.Idle];

        // save start y position of sprite object
        spriteObjectStartYPosition = spriteTransform.localPosition.y;
    }
        public override void Init()
        {
            inventoryController  = GetComponent <PlayerInventoryController>();
            playerAnimController = GetComponent <PlayerAnimationController>();

            isPlayerInAction.value = false;
        }
    private void Awake()
    {
        m_Rigidbody = GetComponent <Rigidbody>();
        ac          = GetComponent <PlayerAnimationController>();

        if (OnLandEvent == null)
        {
            OnLandEvent = new UnityEvent();
        }
        if (OnPlayerWasShot == null)
        {
            OnPlayerWasShot = new UnityEvent();
        }
        if (OnPlayerDied == null)
        {
            OnPlayerDied = new UnityEvent();
        }
        if (OnBackActionTriggered == null)
        {
            OnBackActionTriggered = new UnityEvent();
        }
        if (OnShowScoreboardActionTriggered == null)
        {
            OnShowScoreboardActionTriggered = new UnityEvent();
        }
        if (OnCancelActionTriggered == null)
        {
            OnCancelActionTriggered = new UnityEvent();
        }

        shootCoolDownCounter = shootCoolDown;
    }
Example #15
0
 //expected to be a turn end
 public void BasicAttackEnd()
 {
     selfanim = null;
     //model.transform.forward = direction;
     self.transform.forward = direction;
     model = null;
 }
    /**
     *  Resets the camera and player position the game configuration
     */
    public void StartGame()
    {
        if (!startUp && !tutorialStarted)
        {
            if (PlayerPrefs.GetString("tutorialCompleted", "false") == "false")
            {
                EnableTutorial();
            }
        }
        player.transform.rotation                = Quaternion.Euler(0, 0, 0);
        _animController                          = player.GetComponent <PlayerAnimationController>();
        UI.GetComponent <Canvas>().enabled       = true;
        UI.GetComponent <ScoreCounter>().enabled = true;


        player.GetComponent <Rigidbody>().transform.position = new Vector3(0, 1.15f, 0);
        player.GetComponent <PlayerController>().enabled     = true;
        _animController.StartGame();
        camera.GetComponent <CameraFollowScript>().enabled = true;
        this.GetComponentInChildren <Canvas>().enabled     = false;
        started = true;
        for (int i = 0; i < renderDistance; i++)
        {
            if (tutorialStarted)
            {
                chunkGenerator.GetComponent <ChunkGenerator>().generateChunk(new Vector3(90, 0, 0), Quaternion.Euler(0, 90, 0), true);
            }
            else
            {
                chunkGenerator.GetComponent <ChunkGenerator>().generateChunk(new Vector3(90, 0, 0), Quaternion.Euler(0, 90, 0), false);
            }
        }
    }
 private void Awake()
 {
     controllerCount++;
     this.controllerId   = controllerCount;
     rbody               = GetComponent <Rigidbody2D>();
     animationController = GetComponent <PlayerAnimationController>();
     if (animationController != null)
     {
         animationController.AnimationEvent += AnimationController_AnimationEvent;
     }
     this.playerCharacter = GetComponent <Player>();
     if (this.HUDPrefab != null)
     {
         this.HUD = Instantiate <HUD>(HUDPrefab);
         this.HUD.transform.parent = this.gameObject.transform;
         this.HUD.Controller       = this;
     }
     if (this.HUD == null)
     {
         this.HUD = GetComponentInChildren <HUD>();
         if (this.HUD)
         {
             this.HUD.Controller = this;
         }
     }
     if (this.PauseMenuPrefab != null)
     {
         this.pauseMenu = Instantiate(PauseMenuPrefab);
         this.pauseMenu.transform.parent = this.gameObject.transform;
         this.pauseMenu.Controller       = this;
         this.pauseMenu.Hide();
     }
 }
Example #18
0
 //expected to be a turn start for a "Neven"-like unit
 public void BasicAttackStart()
 {
     selfanim = self.transform.Find("Model").GetComponent <PlayerAnimationController>();
     selfanim.myanim.SetTrigger("AttackKick2Trigger");
     model = self.transform.Find("Model").gameObject;
     self.transform.Find("SlashKick").GetComponent <ParticleSystem>().Play();
 }
Example #19
0
 //expected to be a turn end
 public void CastFireEnd()
 {
     selfanim = null;
     //model.transform.forward = direction;
     self.transform.forward = direction;
     model = null;
 }
Example #20
0
    void Start()
    {
        bubbleDelayTime    = 0.2f;
        animatorController = GetComponent <PlayerAnimationController>();
        PlayerNetWorkData data = GameGlobalData.playerList[fd];
        float             posx = data.initPosition.x;
        float             posy = data.initPosition.y;
        int   row  = (int)Mathf.Abs(posy / GameConst.tileHeight);
        float posz = GameConst.staticLayers[row].position.z;

        transform.position = new Vector3(posx, posy, posz);
        GameGlobalData.robotList.Add(fd, this);
        movement             = GetComponent <RobotMovement>();
        movement.speed       = data.speed;
        movement.maxSpeed    = data.maxSpeed;
        movement.maxDistance = data.maxDistance;
        bubbleCount          = data.bubbleCount;
        maxBubbleCount       = data.maxBubbleCount;
        power         = data.power;
        maxPower      = data.maxPower;
        boomTime      = data.boomTime;
        bubbles       = new List <Bubble>();
        colliderBox   = GetComponent <PlayerColliderBox>();
        preBubbleList = new List <BubbleData>();
    }
Example #21
0
 private void Awake()
 {
     animationController        = GetComponentInParent <PlayerAnimationController>();
     mainCam                    = Camera.main;
     playerState.throwingObject = false;
     ResetState();
 }
Example #22
0
    public override void OnStartLocalPlayer()
    {
        localPlayer = this;

        CmdSetPlayerID(Network.player.ipAddress);

        inventory = GetComponent <PlayerInventory> ();

        animationController = GetComponent <PlayerAnimationController> ();

        uiManager = GameObject.FindObjectOfType <UIManager> ();
        if (!uiManager)
        {
            Debug.LogException(new System.Exception("No UIManager object found in scene"));
        }


        playerMesh       = transform.Find("Player Model/Mesh").gameObject;     // Set mesh to "Local Player Mesh" layer, which is culled by player's camera
        playerMesh.layer = 8;                                                  // ...so the player doesn't see his own body

        playerHands = transform.Find("Camera/Player Hands").gameObject;
        playerHands.SetActive(true);

        foreach (Transform child in transform.Find("Player Model").GetComponentsInChildren <Transform>())
        {
            if (child.tag == "Right Hand Third Person")
            {
                thirdPersonRightHand = child.gameObject;
                break;
            }
        }

        foreach (Transform child in thirdPersonRightHand.GetComponentsInChildren <Transform>())
        {
            child.gameObject.layer = 8;
        }

        // Enable camera and controller components for just the local instance

        camera         = GetComponentInChildren <Camera> ();
        camera.enabled = true;

        Debug.Log(camera);

        audioListener         = GetComponentInChildren <AudioListener> ();
        audioListener.enabled = true;

        firstPersonController         = GetComponent <CustomFirstPersonController> ();
        firstPersonController.enabled = true;


        uiManager.UpdateInventoryPanelsAfterSync();
        uiManager.EnableCursorLock();

        GameObject.FindObjectOfType <Canvas> ().worldCamera   = camera;
        GameObject.FindObjectOfType <Canvas> ().planeDistance = 0.1f;

        DebugID();
    }
Example #23
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        Debug.Log("Weapon despawn behaviour called");
        PlayerAnimationController playerAnimationBehaviour = animator.transform.GetComponentInParent <PlayerAnimationController> ();         // Search in parent in case the player is a child of a boat.

        playerAnimationBehaviour.GetComponent <PlayerAnimationController> ().SpawnItemThirdPerson();                                         // Note that GetComponentInParent starts on the current object so no worries.
        animator.ResetTrigger(PlayerAnimationController.PlayerAnimatorTriggerForceHolster);
    }
Example #24
0
 // Use this for initialization
 void Start()
 {
     leftoff             = 20;
     rightoff            = 20;
     downoff             = 25;
     upoff               = 15;
     animationController = GetComponent <PlayerAnimationController>();
 }
 void Awake()
 {
     TutorialController.PlayerBeh      = this;
     GameInput.Instance.playerBeh      = this;
     GameController.Instance.PlayerBeh = this;
     animController = GetComponentInChildren <PlayerAnimationController>();
     rig2D          = GetComponent <Rigidbody2D>();
 }
Example #26
0
 public void Init(PlayerAnimationController animationController, Transform playerTras, int playerNmber, bool isLocalPlayer, bool isDead, System.Action <int, Vector3, float> moveCallback)
 {
     this.isLocalPlayer = isLocalPlayer;
     this.isDead        = isDead;
     this.move.Init(animationController, playerTras, playerNmber, isDead, moveCallback);
     this.animationController = animationController;
     this.animationController.Init(playerNmber);
 }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        Debug.Log("Weapon despawn behaviour called");
        PlayerAnimationController playerAnimationBehaviour = animator.transform.root.GetComponent <PlayerAnimationController> ();

        playerAnimationBehaviour.GetComponent <PlayerAnimationController> ().SpawnItemThirdPerson();
        animator.ResetTrigger(PlayerAnimationController.PlayerAnimatorTriggerForceHolster);
    }
    private void Start()
    {
        rb = GetComponent <Rigidbody>();
        animationController = GetComponent <PlayerAnimationController>();

        rb.constraints         = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
        origGroundCheckDistane = groundCheckDistance;
    }
Example #29
0
 private void Awake()
 {
     playerState.meleeing = false;
     lastMeleeAttackTime  = 0f;
     coll = GetComponentInChildren <CapsuleCollider>();
     animationController = GetComponentInParent <PlayerAnimationController>();
     audMelee            = GetComponent <AD_Melee>();
 }
Example #30
0
 private void Start()
 {
     gameOverHeight = GameObject.Find("WaterHeightController").GetComponent <WaterHeightController>().GetMinHeight() - 10.0f;
     player         = GameObject.FindGameObjectWithTag("Player");
     endText        = GameObject.Find("EndText").GetComponent <EndText>();
     pc             = GameObject.Find("PenguinController").GetComponent <PenguinController>();
     pac            = GameObject.Find("sirokuma").GetComponent <PlayerAnimationController>();
 }
Example #31
0
    void Start()
    {
        controller = GetComponent<Controller2D>();
        animator = GetComponent<PlayerAnimationController>();
        playerCollider = GetComponent<BoxCollider2D>();

        gravity = -1000;
        maxJumpVelocity = (Mathf.Abs(gravity) * (timeToJumpApex)) * ((Mathf.Pow(maxJumpHeight, -0.5221f)) * 0.1694f) * maxJumpHeight;
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
        //CalculatePhysics();
        isAttacking = false;
        attackLaunched = false;
        isJumping = false;
        flinching = false;
        deathStanding = false;
        knockBack = false;
        climbingUpMovement = false;
        uninterupatble = false;
        callingActivateAbility = false;
    }
	// Use this for initialization
	void Start () {
        myCharacterController = this.GetComponent<Prime31.CharacterController2D>();
        myPlayerCharacter = this.GetComponent<PlayerCharacter>();
        myAnimationController = this.GetComponent<PlayerAnimationController>();
        myColliderController = this.GetComponent<PlayerColliderController>();
	}
Example #33
0
 void Start()
 {
     playerWeaponController = GetComponent<PlayerWeaponController>();
     playerAnimationController = GetComponent<PlayerAnimationController>();
     characterMovementController = GetComponent<CharacterMovementController>();
 }
Example #34
0
 void Start()
 {
     _controller = GetComponent<CharacterController>();
     _animationController = GetComponent<PlayerAnimationController>();
 }
Example #35
0
 // Use this for initialization
 void Start()
 {
     jumping = 0;
     grounded = false;
     body = GetComponent<Rigidbody>();
     playerAnimationController = GetComponent<PlayerAnimationController>();
     avaCol = GetComponent<AvatarCollision>();
     avaCol.spriteRenderer = GetComponent<SpriteRenderer> ();
     jumpPressed = false;
     wallGlide = false;
     facing = 1;
     sound = GetComponent<AudioSource> ();
 }