Beispiel #1
0
    private void HandleInput(bool isArmed, PlayerInputData inputData)
    {
        if (!inputData.pressedInputs[5]) // let go of guard
        {
            stateMachine.ChangeState(playerController.standingState);
        }

        if (isArmed)
        {
            if (playerController.playerInputData.pressedInputs[1]) // right
            {
                BasicMovement.FaceRight(movementController);
            }
            else if (playerController.playerInputData.pressedInputs[2]) // left
            {
                BasicMovement.FaceLeft(movementController);
            }
        }
        else // Not armed
        {
            if (playerController.playerInputData.pressedInputs[1] ||
                playerController.playerInputData.pressedInputs[2]) // right
            {
                stateMachine.ChangeState(playerController.walkingState);
                return;
            }
        }
    }
Beispiel #2
0
 void Start()
 {
     mainCamera    = Camera.main;
     rb            = GetComponent <Rigidbody>();
     lastTime      = Time.time + coolDownShoot;
     basicMovement = GetComponent <BasicMovement>();
 }
    // private bool shooting = false;

    //should maybe be Damagable or something

    // Use this for initialization
    void Start()
    {
        m_BasicMovement = GetComponent <BasicMovement>();
        m_Anim          = GetComponent <Animator>();
        m_AudioSource   = GetComponent <AudioSource>();
        m_Transform     = GetComponent <Transform>();
        m_BoxCollider   = GetComponent <BoxCollider2D>();
        m_HealthScript  = GetComponent <HealthScript>();
        m_HealthScript.onHurtDelegate      = onHurt;
        m_HealthScript.onInvulnEndDelegate = onInvulnEnd;
        m_HealthScript.onDeathDelegate     = onDeath;
        m_Flash          = GetComponent <Flash>();
        basicShootScript = GameObject.Find("BasicWeapon").GetComponent <PlayerShoot>();
        powerShootScript = GameObject.Find("PowerWeapon").GetComponent <PlayerShoot>();
        energy           = 0.0f;
        shield           = GameObject.Find("PlayerShield");
        shield.SetActive(false);

        m_Grounded = false;
        if (GameController.respawnPosition != null)
        {
            transform.position = (Vector3)GameController.respawnPosition;
        }

        updatePositionReference();
        PlayerStartEvent.Raise();
    }
Beispiel #4
0
    // Start the game
    public GameObject StartGame(Transform parentTransform, Vector3 spawnPoint, Quaternion spawnRotation, SettingsLevel settings)
    {
        // Create the character at the right spawnlocation
        GameObject current = Instantiate(currentCharacter, spawnPoint, spawnRotation);

        current.transform.parent = parentTransform;
        character = current.GetComponent <BasicMovement>();

        // Set the name+character name
        settings.SetCharacter(name, currentCharacter.name);
        character.Settings(settings);

        // Set the right spawnpoint to the respawn location
        character.spawnPoint    = spawnPoint;
        character.rotationPoint = spawnRotation;

        // Reset the menu
        if (menuCharacter != null)
        {
            name = menuCharacter.name;
            clr  = menuCharacter.clr;
        }
        // Set the color of the character
        character.SetBasics(name, clr);

        // Set the right game state
        game = true;
        menu = false;

        // Return the current character that the controller controls
        return(current);
    }
    void SpawnHuman()
    {
        BasicMovement human = GameObject.Instantiate(HumanPrefab, Ground).GetComponent <BasicMovement>();

        GroundManager.Instance.AddHuman(human);
        spawnCount++;
    }
Beispiel #6
0
    void Start()
    {
        playerTarget   = null;
        nextAttackTime = 0.0f;
        canSeePlayer   = false;
        canHearPlayer  = false;

        EnemyChildDelegate losChild = lineOfSight.AddComponent <EnemyChildDelegate>();

        losChild.Parent   = this;
        losChild.ChildTag = "LoS";

        EnemyChildDelegate earChild = hearingRadius.AddComponent <EnemyChildDelegate>();

        earChild.Parent   = this;
        earChild.ChildTag = "Ear";

        EnemyChildDelegate atkChild = attackZone.AddComponent <EnemyChildDelegate>();

        atkChild.Parent   = this;
        atkChild.ChildTag = "Atk";

        healthBar.MaxHealth = health;

        sr          = GetComponent <SpriteRenderer>();
        losCollider = lineOfSight.GetComponent <PolygonCollider2D>();

        if (!sr.flipX)
        {
            lineOfSight.transform.Rotate(0f, 0f, 180f);
            attackZone.transform.Rotate(0f, 0f, 180f);
        }
    }
Beispiel #7
0
 void Start()
 {
     gameOverText = GameObject.FindGameObjectWithTag("gameOverText");
     gameOverText.SetActive(false);
     basicMovement = GameObject.FindGameObjectWithTag("boat").GetComponent <BasicMovement>();
     //images = GameObject.Find("Canvas")
 }
    void FixedUpdate()
    {
        SpeedFactor = Input.GetAxis("Horizontal");



//------------------------------------------

        if (SpeedFactor > 0)
        {
            BasicMovement.LookLeft();
        }


        else if (SpeedFactor < 0)
        {
            BasicMovement.LookRight();
        }

//------------------------------------------
        if (Input.GetAxis("Aim") > 0.5f)
        {
        }



        VerticalVelocity = Rigidbody2D.velocity.y;

        if (Mathf.Abs(SpeedFactor) > 0.2f)
        {
            BasicMovement.Walk(SpeedFactor);
        }

        IsJumping = Input.GetAxis("Jump") == 1.0f;
    }
Beispiel #9
0
    public virtual void Start()
    {
        characterAI   = GetComponent <BasicAI>();
        basicMovement = GetComponent <BasicMovement>();
        agent         = GetComponent <NavMeshAgent>();
        originalSpeed = agent.speed;
        anim          = transform.GetChild(0).gameObject.GetComponent <Animator>();
        // Find all waypoitns
        var waypoints = GameObject.FindGameObjectsWithTag("Waypoint");

        // Only add waypoints that are close to the enemy so they don't run across the map.
        foreach (var waypoint in waypoints)
        {
            WaypointTransforms.Add(waypoint.transform);
        }

        var wayPointTransformsToRemove = new List <Transform>();

        // Remove waypoints that are too far away
        foreach (var waypointTransform in WaypointTransforms)
        {
            if (!(Vector3.Distance(waypointTransform.position, transform.position) <= maxWayPointRange) || !WaypointInLOS(waypointTransform))
            {
                wayPointTransformsToRemove.Add(waypointTransform);
            }
        }
        WaypointTransforms.RemoveAll(x => wayPointTransformsToRemove.Contains(x));

        if (WaypointTransforms.Count > 0)
        {
            WaypointTransforms.Sort((a, b) => (Vector3.Distance(a.position, transform.position).CompareTo(Vector3.Distance(b.position, transform.position))));
            IsPatrolling(true);
        }
    }
Beispiel #10
0
    // Use this for initialization
    void Start()
    {
        m_physics  = GetComponent <PhysicsSS> ();
        m_movement = GetComponent <BasicMovement> ();

        m_oldVelocity = new Vector2();
    }
Beispiel #11
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Bob")
        {
            if (!isFollowing)
            {
                thePlayer = GameObject.FindGameObjectWithTag("Bob").GetComponent <BasicMovement>();

                followTarget = thePlayer.radioFollowingPoint;

                isFollowing = true;
                thePlayer.followingRadio = this;
            }
        }

        if (other.tag == "Doug")
        {
            if (!isFollowing)
            {
                thePlayer = GameObject.FindGameObjectWithTag("Doug").GetComponent <BasicMovement>();

                followTarget = thePlayer.radioFollowingPoint;

                isFollowing = true;
                thePlayer.followingRadio = this;
            }
        }
    }
    private void GoToCharacter()
    {
        int nr = 0;

        foreach (GameObject menuItem in menuItems)
        {
            if (nr == index)
            {
                menuItem.SetActive(true);
            }
            else
            {
                menuItem.SetActive(false);
            }

            nr++;
        }

        if (current != null)
        {
            Destroy(current);
            current = null;
        }

        current = Instantiate(characters[index], spawnPoint.position, spawnPoint.rotation);
        current.transform.parent     = this.transform;
        current.transform.localScale = new Vector3(100, 100, 100);

        BasicMovement character = current.GetComponent <BasicMovement>();

        character.SetBasics(name, clr);
    }
Beispiel #13
0
        public Player(Room room)
        {
            instance = this;

            SetPosition(room.X + Global.screenWidth / 2, room.Y + Global.screenHeight / 2 + 116);
            sprite = SpriteData.GetAnimation("player");
            AddGraphic(sprite);


            AddCollider(new BoxCollider(10, 16, Global.Tags.Player));
            Collider.SetOrigin(5, 16);

            movement = new BasicMovement(200, 200, 20);
            movement.AddCollision(Global.Tags.Wall);
            movement.Collider = Collider;

            AddComponent(movement);
            AddComponent(new YSort());

            AddComponent(state);
            state.ChangeState(States.Stop);

            damageCollider = AddCollider(new CircleCollider(16, Global.Tags.Enemy));
            damageCollider.SetOrigin(16, 32);
        }
    void Start()
    {
        cameraScript   = Camera.GetComponent <CameraScript>();
        paintSpawn     = Paint.GetComponent <PaintSpawn>();
        playerMovement = Player.GetComponent <BasicMovement>();
        ChangeStates(States.Paint);
        paintcamera.enabled = true;
        movecamera.enabled  = false;
        Scene  currentScene = SceneManager.GetActiveScene();
        string sceneName    = currentScene.name;

        if (sceneName == "Level1 Tutorial4")
        {
            sawBlades[0].GetComponent <SawBlades>().enabled         = false;
            sawBlades[1].GetComponent <SawBlades>().enabled         = false;
            sawBlades[0].GetComponent <PolygonCollider2D>().enabled = false;
            sawBlades[1].GetComponent <PolygonCollider2D>().enabled = false;
        }
        else
        {
            sawBlades = null;
        }

        if (sceneName == "Level1 Tutorial5")
        {
            greengoal.GetComponent <Rigidbody2D>().gravityScale = 0;
        }
        else
        {
            greengoal = null;
        }
    }
    void UpdateSinglePiece(GameObject piece)
    {
        //add the basic movement script to our newly generated piece to make it move towards the player
        BasicMovement movement = piece.AddComponent <BasicMovement>();

        //make it move with a speed of globalspeed
        movement.movespeed = -globalSpeed;

        //set the rotate speed to the lamp (directional light) rotate speed
        if (lampMovement != null)
        {
            movement.rotateSpeed = lampMovement.rotateSpeed;
        }

        //create an endpoint for this piece
        GameObject endPoint = new GameObject();

        endPoint.transform.position = piece.transform.position + Vector3.forward * (dimensions.y * scale * Mathf.PI);
        endPoint.transform.parent   = piece.transform;
        endPoint.name = "End Point";

        //change the perlin noise offset to make sure each piece is different from the last one
        offset += randomness;

        //change the obstacle chance which means there will be more obstacles over time
        if (startObstacleChance > 5)
        {
            startObstacleChance -= obstacleChanceAcceleration;
        }
    }
Beispiel #16
0
    public void SetPlayer(PlayerManager mPlayer)
    {
        pManager = mPlayer;

        Image img = gameObject.GetComponent <Image>();

        movement  = mPlayer.gameObject.GetComponent <BasicMovement>();
        img.color = movement.clr;

        ccUI.SetActive(false);
        ultimateUI.SetActive(false);

        foreach (Image circle in colorCircles)
        {
            circle.color = movement.clr;
        }

        if (movement.character.Contains("Ranger"))
        {
            iconCircle.sprite = ranger;
            name.text         = "Ranger";
        }
        else if (movement.character.Contains("Berserker"))
        {
            iconCircle.sprite = berserker;
            name.text         = "Berserker";
        }
    }
Beispiel #17
0
 void Awake()
 {
     bm           = transform.GetComponent <BasicMovement>();
     centerWeight = .1f;
     sigma        = .15f;
     dashChance   = .006f;
 }
Beispiel #18
0
 // Use this for initialization
 void Start()
 {
     bm           = GetComponent <BasicMovement>();
     counterIn    = 0;
     counterOut   = 0;
     bm.previousS = Random.RandomRange(0.0f, 1.0f);
 }
Beispiel #19
0
 public void SetPlayer(BasicMovement bm)
 {
     GetComponent <CameraFollow> ().target = bm.GetComponent <PhysicsSS>();
     GetComponent <CameraFollow> ().initFunct();
     FindObjectOfType <GUIHandler> ().OnSetPlayer(bm);
     CurrentPlayer = bm.gameObject;
 }
Beispiel #20
0
        private void Awake()
        {
            basicMovement = GameObject.FindGameObjectWithTag("Player").GetComponent <BasicMovement>();
            camera        = GetComponent <Camera>();

            StartCoroutine(ShowTheMap());
        }
Beispiel #21
0
    public void Enter()
    {
        animationController.SetSprite(animations.jump[0]);

        movementController.SetCollider(movementController.jumpApexColliderSize, movementController.jumpApexColliderOffset);
        BasicMovement.Jump(movementController, PlayerTimings.PLAYER_JUMP_VELOCITY);
    }
Beispiel #22
0
    // Use this for initialization
    protected virtual void Start()
    {
        m_BoxCollider   = GetComponent <BoxCollider2D>();
        m_BasicMovement = this.GetComponent <BasicMovement>();

        m_Flash = GetComponent <Flash>();
        if (m_Flash == null)
        {
            m_Flash = GetComponentInChildren <Flash>();
            if (m_Flash == null)
            {
                m_Flash = gameObject.AddComponent <Flash>();
            }
        }

        m_Collideable = GetComponent <Collideable>();
        if (m_Collideable == null)
        {
            m_Collideable = gameObject.AddComponent <Collideable>();
        }

        m_DetectMovingPlat = GetComponent <DetectMovingPlat>();
        if (m_DetectMovingPlat == null)
        {
            m_DetectMovingPlat = gameObject.AddComponent <DetectMovingPlat>();
        }
    }
Beispiel #23
0
    public void Enter()
    {
        RunAnimation();

        BasicMovement.StopHorizontal(movementController);
        AdvancedMovement.Crouch(movementController);
    }
Beispiel #24
0
 public void setTarget(BasicMovement c, Vector3 offset, float tolerance = 1f)
 {
     // Debug.Log ("Setting target to: offset: " + offset + " t: " + tolerance);
     m_minDistance  = tolerance;
     m_targetOffset = new Vector3(offset.x, offset.y, 0f);
     CurrentTarget  = c;
 }
        private void Awake()
        {
            basicMovement = GameObject.FindGameObjectWithTag("Player").GetComponent<BasicMovement>();
            camera = GetComponent<Camera>();

            StartCoroutine(ShowTheMap());
        }
    public override CreatureAction PerfectCopy(Creature targetCreature)
    {
        var newMovement = new BasicMovement(targetCreature);

        newMovement._creatureSide = _creatureSide;

        return(newMovement);
    }
    public void Enter()
    {
        timeInSeconds = 0;

        animationController.SetSprite(animations.dash[5]);

        BasicMovement.StopAll(movementController);
    }
Beispiel #28
0
 void Awake()
 {
     rig            = GetComponent <Rigidbody>();
     cc             = GetComponent <CapsuleCollider>();
     bm             = GetComponent <BasicMovement>();
     gm             = GetComponent <GrapplingMovement>();
     groundDetector = transform.Find("GroundDetector");
 }
 private void Awake()
 {
     moveScript = GetComponent <BasicMovement>();
     if (effectPostion == null)
     {
         effectPostion = gameObject.transform;
     }
 }
    public override CreatureAction ImperfectCopy(Creature targetCreature, float errorChance, float minDeviation, float maxDeviation)
    {
        var newMovement = new BasicMovement(targetCreature);

        newMovement._creatureSide = (Direction)ValueMutator.MutateFlat((int)_creatureSide, errorChance, -1, 1);

        return(newMovement);
    }
Beispiel #31
0
 public void Enter()
 {
     RunAnimation();
     movementController.SetPhysicsMaterialSlope(movementController.IsOnSlope());
     BasicMovement.StopHorizontal(movementController, true);
     AdvancedMovement.Crouch(movementController);
     timeInSeconds = 0d;
 }
        public BasicDrawable(float x, float y, Color color, float scale, float rotation)
        {
            this.color = color;
            this.x = x;
            this.y = y;

            this.rotation = rotation;
            this.scale = scale;

            this.movementQueue = new BasicCollection("movementQueue");
            this.actualMovement = null;

            this.hiden = false;
        }
Beispiel #33
0
    void Update()
    {
        Player = GameObject.FindGameObjectWithTag ("Player");
        if (Player != null){
            _Mov = Player.GetComponent<BasicMovement> ();
        }

        if (shake > 0)
        {
            camTransform.localPosition = PlayerPos + Random.insideUnitSphere * shakeAmount;

            shake -= Time.deltaTime * decreaseFactor;
        }
        else
        {
            shake = 0f;
            if(Player != null){
                PlayerPos = new Vector3(Player.transform.position.x,Player.transform.position.y,-10);
                camTransform.localPosition = PlayerPos;
            }
        }
    }
Beispiel #34
0
    void Start()
    {
        // Set variables to objects
        cart = GameObject.Find("Cart").GetComponent<BasicMovement>();

        StartSpawnRate();
        previousSpawn = totalDodges = 0;
        currentTrack = trackNumber.CENTER;
        startSpawn = 500;
        offsetY = 1.5f;
    }
Beispiel #35
0
 // Use this for initialization
 void Start()
 {
     _Mov = Player.GetComponent<BasicMovement>();
     _shake = Camera.main.GetComponent<CameraShake>();
 }
Beispiel #36
0
 public AutoRun(BasicMovement cart)
 {
     this.cart = cart;
 }
Beispiel #37
0
 public MoveTrackRight(BasicMovement cart)
 {
     this.cart = cart;
 }
Beispiel #38
0
 public MoveCart(BasicMovement cart)
 {
     this.cart = cart;
 }
Beispiel #39
0
 void Awake()
 {
     mov = gameObject.GetComponent<BasicMovement>();
 }
 public void addMovement(BasicMovement m)
 {
     m.drawable = this;
     this.movementQueue.add(m);
 }
Beispiel #41
0
    void Start()
    {
        // Set variables to objects
        cart = GameObject.Find("Cart").GetComponent<BasicMovement>();

        topLeftCube = GameObject.Find("TopLeft");
        topCenterCube = GameObject.Find("TopCenter");
        topRightCube = GameObject.Find("TopRight");
        middleLeftCube = GameObject.Find("MiddleLeft");
        middleCenterCube = GameObject.Find("MiddleCenter");
        middleRightCube = GameObject.Find("MiddleRight");

        topLeft = topLeftCube.GetComponent<CubeGridCollider>();
        topCenter = topCenterCube.GetComponent<CubeGridCollider>();
        topRight = topRightCube.GetComponent<CubeGridCollider>();
        middleLeft = middleLeftCube.GetComponent<CubeGridCollider>();
        middleCenter = middleCenterCube.GetComponent<CubeGridCollider>();
        middleRight = middleRightCube.GetComponent<CubeGridCollider>();

        StartSpawnRate();
        previousSpawn = totalHits = 0;
        startSpawn = 1000;
    }
        public void update(GameTime gameTime)
        {
            if(this.movementQueue.hasNext() && this.actualMovement == null)
            {
                this.actualMovement = (BasicMovement) this.movementQueue.first();
                this.movementQueue.remove(this.actualMovement);
                this.actualMovement.onReady();
            }

            if (this.actualMovement != null)
            {
                if (!this.actualMovement.isPlaying())
                    this.actualMovement.play();

                this.actualMovement.update(gameTime);

                if (this.actualMovement.isFinished())
                    this.actualMovement = null;
            }

            onUpdate(gameTime);
        }
Beispiel #43
0
 public RunMovement(BasicMovement cart)
 {
     this.cart = cart;
 }
Beispiel #44
0
 public MoveTrackLeft(BasicMovement cart)
 {
     this.cart = cart;
 }
Beispiel #45
0
 public void Initialize(BasicMovement cart)
 {
     this.cart = cart;
 }