Пример #1
0
        void FindPlayer()
        {
            if (nextTimeToSearch <= Time.time)
            {
                if (_hero == 0)
                {
                    searchResult = GameObject.FindGameObjectWithTag("Ionian");
                }
                else if (_hero == 1)
                {
                    searchResult = GameObject.FindGameObjectWithTag("Athenian");
                }
                else if (_hero == 2)
                {
                    searchResult = GameObject.FindGameObjectWithTag("Spartan");
                }
                else if (_hero == 3)
                {
                    searchResult = GameObject.FindGameObjectWithTag("Achilles");
                }

                if (searchResult != null)
                {
                    target = searchResult;
                    motorToWatch = target.GetComponent<PlatformerMotor2D>();
                    A = target.GetComponent<AchillesHealth>();

                }
                nextTimeToSearch = Time.time + 0.5f;
            }
        }
Пример #2
0
        public void DoAction(PlatformerMotor2D motor, TriggerAction action, bool exitFreeMode)
        {
            switch(action) {
            case TriggerAction.EnableRestrictedAreaIfFreemode:
                if (motor.motorState == PlatformerMotor2D.MotorState.FreedomState) {
                    motor.EnableRestrictedArea();
                }
                break;
            case TriggerAction.EnableRestrictedArea:
                motor.EnableRestrictedArea();
                break;
            case TriggerAction.DisableRestrictedAreaIfFreemode:
                if (motor.motorState == PlatformerMotor2D.MotorState.FreedomState) {
                    motor.DisableRestrictedArea();
                }
                break;
            case TriggerAction.DisableRestrictedArea:
                motor.DisableRestrictedArea();
                break;
            }

            if (exitFreeMode)
            {
                if (motor.motorState == PlatformerMotor2D.MotorState.FreedomState)
                {
                    motor.FreedomStateExit();
                }
            }
        }
        // Use this for initialization
        void Start()
        {
            _motor = GetComponent<PlatformerMotor2D>();
            _animator = visualChild.GetComponent<Animator>();
            _animator.Play("Idle");

            _motor.onJump += SetCurrentFacingLeft;
        }
Пример #4
0
 // Use this for initialization
 void Start()
 {
     _motor = GetComponent<PlatformerMotor2D>();
     _eMaster = GetComponent<EnemyAIMaster>();
     _animator = GetComponent<Animator>();
     EH = GetComponent<EnemyHealth>();
     _pMaster = _eMaster._pMaster;
 }
Пример #5
0
    // after leave freedom state for ladders
    void FreedomStateRestore(PlatformerMotor2D motor)
    {
        if (_restored) // do not enter twice
            return;

        _restored = true;
        _motor.enableOneWayPlatforms = _enableOneWayPlatforms;
        _motor.oneWayPlatformsAreWalls = _oneWayPlatformsAreWalls;
    }
Пример #6
0
    // before enter en freedom state for ladders
    void FreedomStateSave(PlatformerMotor2D motor)
    {
        if (!_restored) // do not enter twice
            return;

        _restored = false;
        _enableOneWayPlatforms = _motor.enableOneWayPlatforms;
        _oneWayPlatformsAreWalls = _motor.oneWayPlatformsAreWalls;
    }
Пример #7
0
    void Start()
    {
        _controller = GetComponent<PlayerMasterController>();
        showShadow = shadow.GetComponent<Renderer>();
        _motor = GetComponent<PlatformerMotor2D>();
        _animator = GetComponent<Animator>();

        _motor.onJump += SetCurrentFacingLeft;
    }
        // Use this for initialization
        void Start()
        {
            audioSource = GetComponent<AudioSource>();
            jump = Resources.Load("Audio/jump") as AudioClip;
            _player = GetComponent<Player>();
            _motor = GetComponent<PlatformerMotor2D>();
            _animator = visualChild.GetComponent<Animator>();
            _animator.Play("Idle");

            _motor.onJump += SetCurrentFacingLeft;
        }
Пример #9
0
    void Awake()
    {
        EH = GetComponent<EnemyHealth>();
        stopDist = 1.5f;
        _canAttack = true;

        _motor = GetComponent<PlatformerMotor2D>();
        _anim = GetComponent<EnemyAIAnimator>();
        _hero = PlayerPrefs.GetInt("Hero");

        AI = this.gameObject;

        //Determine which hero to look for and go after;
        switch (_hero)
        {
            case 0:
                Debug.Log("I am from Ionia");
                target = GameObject.FindGameObjectWithTag("Ionian");
                targetT = target.transform;
                IS = target.GetComponent<IonianStatistics>();
                IH = target.GetComponent<IonianHealth>();
                IXP = target.GetComponent<IonianEXP>();
                _pMaster = target.GetComponent<PlayerMaster>();
                break;
            case 1:
                Debug.Log("I am from Athens");
                target = GameObject.FindGameObjectWithTag("Athenian");
                targetT = target.transform;
                ATS = target.GetComponent<AthenianStatistics>();
                ATH = target.GetComponent<AthenianHealth>();
                ATXP = target.GetComponent<AthenianEXP>();
                _pMaster = target.GetComponent<PlayerMaster>();
                break;
            case 2:
                Debug.Log("I am from Sparta");
                target = GameObject.FindGameObjectWithTag("Spartan");
                targetT = target.transform;
                SS = target.GetComponent<SpartanStatistics>();
                SH = target.GetComponent<SpartanHealth>();
                SXP = target.GetComponent<SpartanEXP>();
                _pMaster = target.GetComponent<PlayerMaster>();
                break;
            case 3:
                Debug.Log("I am Greek");
                target = GameObject.FindGameObjectWithTag("Achilles");
                targetT = target.transform;
                AS = target.GetComponent<AchillesStatistics>();
                AH = target.GetComponent<AchillesHealth>();
                AXP = target.GetComponent<AchillesEXP>();
                _pMaster = target.GetComponent<PlayerMaster>();
                break;
        }
    }
Пример #10
0
        private void FixedUpdate()
        {
            if (_state == State.Down)
            {
                _time += Time.fixedDeltaTime;

                _mpMotor.position = new Vector3(
                    _mpMotor.position.x,
                    _moveDownFunc(_originalY + heightReached, _originalY, Mathf.Clamp01(_time / moveDownDuration)),
                    transform.position.z);

                if (_time >= moveDownDuration)
                {
                    _state = State.None;

                    if (_player != null && _player.connectedPlatform == _mpMotor)
                    {
                        _state = State.Up;
                        _time = 0;
                    }
                    else
                    {
                        _player = null;
                    }
                }
            }

            if (_state == State.Up)
            {
                _time += Time.fixedDeltaTime;

                _mpMotor.position = new Vector3(
                    _mpMotor.position.x,
                    _moveUpFunc(_originalY, _originalY + heightReached, Mathf.Clamp01(_time / moveUpDuration)),
                    transform.position.z);

                if (_time >= moveUpDuration)
                {
                    _state = State.Down;
                    _time = 0;

                    if (_player.connectedPlatform == _mpMotor)
                    {
                        _player.DisconnectFromPlatform();
                        _player.velocity += Vector2.up * playerSpeedYAtApex;
                        _player = null;
                    }
                }
            }
        }
Пример #11
0
        // Use this for initialization
        void Start()
        {
            target = GameObject.FindGameObjectWithTag("Achilles");
            motorToWatch = target.GetComponent<PlatformerMotor2D>();

            A = target.GetComponent<AchillesHealth>();
            motorToWatch.onLanded += OnFallFinished;
            fallText.color = Color.white;

            _hero = PlayerPrefs.GetInt("Hero");
        }
Пример #12
0
 // Use this for initialization
 void Start()
 {
     //Get the motor of the player
     _motor = GetComponent <PlatformerMotor2D>();
 }
Пример #13
0
 // Use this for initialization
 void Start()
 {
     _motor = GetComponent <PlatformerMotor2D>();
 }
Пример #14
0
 // Use this for initialization
 void Start()
 {
     _motor    = GetComponent <PlatformerMotor2D>();
     container = GameObject.Find("Character_Container").GetComponent <CharacterSelector>();
     container.rigisterNewCharacter(this);
 }
Пример #15
0
 void Awake()
 {
     ATS = GetComponent<AthenianStatistics>();
     _motor = GetComponent<PlatformerMotor2D>();
 }
Пример #16
0
 // Use this for initialization
 void Start()
 {
     _motor = GetComponent<PlatformerMotor2D>();
     container = GameObject.Find("Character_Container").GetComponent<CharacterSelector>();
     container.rigisterNewCharacter(this);
 }
Пример #17
0
 // Use this for initialization
 void Start()
 {
     _motor = gameObject.GetComponent <PlatformerMotor2D>();
 }
Пример #18
0
 // Start is called before the first frame update
 void Start()
 {
     animator             = this.gameObject.GetComponentInChildren <Animator>();
     plataformerAnimation = this.gameObject.GetComponent <PC2D.PlatformerAnimation2D>();
     plataformerMotor     = this.gameObject.GetComponent <PlatformerMotor2D>();
 }
 private void RefsInit()
 {
     _motor       = GetComponent <PlatformerMotor2D>();
     playerSprite = GetComponent <SpriteRenderer>();
 }
 // Use this for initialization
 void Start()
 {
     _motor   = GetComponent <PlatformerMotor2D>();
     animator = GetComponent <PlatformerAnimation2D>();
     attacktrigger.enabled = false;
 }
Пример #21
0
 // Use this for initialization
 void Start()
 {
     _motor    = GetComponent <PlatformerMotor2D>();
     _animator = GetComponent <Animator>();
 }
 private void Awake()
 {
     _motor = GetComponent <PlatformerMotor2D>();
 }
Пример #23
0
 void Start()
 {
     singleton       = this;
     _motor          = gameObject.GetComponent <PlatformerMotor2D>();
     _bubbleDialogue = gameObject.GetComponentInChildren <SpriteAnimator>();
 }
Пример #24
0
        // Use this for initialization
        void Start()
        {
            _motor = GetComponent<PlatformerMotor2D>();
            movement = -1;

            // Find objects generally pretty bad but this is a demo :)
            SimpleAI[] ais = FindObjectsOfType<SimpleAI>();

            for (int i = 0; i < ais.Length; i++)
            {
                Physics2D.IgnoreCollision(GetComponent<Collider2D>(), ais[i].GetComponent<Collider2D>());
            }

            _motor.onWallJump +=
                dir =>
                {
                    // Since the motor needs to be pressing into the wall to wall jump, we switch direction after the jump.
                    movement = Mathf.Sign(dir.x);
                };
        }
Пример #25
0
 void Awake()
 {
     IS = GetComponent<IonianStatistics>();
     _motor = GetComponent<PlatformerMotor2D>();
 }
Пример #26
0
 private void PlayerContact(PlatformerMotor2D player)
 {
     _mpMotor.onPlatformerMotorContact -= PlayerContact;
     _state = State.Darken;
 }
Пример #27
0
 // Use this for initialization
 void Start()
 {
     duaeState   = PlayerState.Cloaked;
     motorScript = GetComponent <PlatformerMotor2D> ();
 }
Пример #28
0
 void Awake()
 {
     S = GetComponent<SpartanStatistics>();
     _motor = GetComponent<PlatformerMotor2D>();
 }
Пример #29
0
 // Use this for initialization
 void Start()
 {
     _motor = GetComponent<PlatformerMotor2D>();
 }
 void Awake()
 {
     #region TOUCH VARIABLE DECLARATION
     #if !UNITY_ANDROID && !UNITY_IPHONE && !UNITY_BLACKBERRY && !UNITY_WINRT || UNITY_EDITOR
     //nothing specific for Unity PC. This was just to get rid of touch variables when not needed;
     #else
     //Screen With for swipe controls
     mid = Screen.width / 2.0f;
     #endif
     #endregion
     _hero = PlayerPrefs.GetInt("Hero");
     _master = GetComponent<PlayerMaster>();
     _motor = GetComponent<PlatformerMotor2D>();
 }
Пример #31
0
        private void PlayerContact(PlatformerMotor2D player)
        {
            if (_state == State.None)
            {
                _state = State.Up;
                _time = 0;

            }

            _player = player;
        }
Пример #32
0
 // Use this for initialization
 void Start()
 {
     _isHoldingBlock = false;
     _motor          = GetComponent <PlatformerMotor2D>();
     _collider2D     = GetComponent <BoxCollider2D>();
 }
Пример #33
0
 private void PlayerContact(PlatformerMotor2D player)
 {
     _mpMotor.onPlatformerMotorContact -= PlayerContact;
     _state = State.Darken;
 }
 void Awake()
 {
     motor = player.GetComponent <PlatformerMotor2D>();
 }