Esempio n. 1
0
        private void Start()
        {
            _coll             = GetComponent <CollisionHandler>();
            _rb               = GetComponent <Rigidbody2D>();
            _anim             = GetComponent <AnimationHandler>();
            _anim             = GetComponentInChildren <AnimationHandler>();
            _vfx              = GetComponent <VfxHandler>();
            _ghost            = GetComponent <GhostEffect>();
            _healthManager    = GetComponent <HealthManager>();
            _attackManager    = GetComponent <CharacterAttackManager>();
            _capsuleCollider  = GetComponent <CapsuleCollider2D>();
            _input            = GetComponent <IInputController>();
            _gameManager      = GameManager.Instance;
            _coll.OnGrounded += ResetIsJumping;
            _coll.OnWalled   += ResetIsJumping;

            _groundTouch   = true;
            _canStillJump  = true;
            _wasOnWall     = false;
            _side          = 1;
            _capsuleOffset = _capsuleCollider.offset;
            _capsuleSize   = _capsuleCollider.size;

            if (_showDebug)
            {
                CursedDebugger.Instance.Add("State", () => _state.ToString());
            }
        }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (ghost == null)
        {
            ghost = GameObject.Find("Ghost(Clone)");
            if (ghost == null)
            {
                ghost = GameObject.Find("Ghost");
            }
        }
        else
        {
            m_GhostEffect = ghost.GetComponent <GhostEffect>();
        }


        alha = meshrender.material.color.a;
        if (m_GhostEffect != null)
        {
            m_ControlType = m_GhostEffect.ControlType;
        }

        if (life > 0 && IsAct == true)
        {
            life--;
        }

        if (IsAct == false)
        {
            if (meshrender.material.color.a > 0)
            {
                meshrender.material.color -= new Color(0, 0, 0, 0.1f);
            }
        }

        switch (m_ControlType)
        {
        case CServer.CONTROL_TYPE.GHOST:
            //常に見える状態
            UpdateGhost();
            break;

        case CServer.CONTROL_TYPE.HUMAN:
            //見えない状態
            UpdateHuman();

            break;
        }
    }
Esempio n. 3
0
        // Creates an Event with the same properties as the given event
        public Event(Event other)
        {
            type                 = other.type;
            actionToPerform      = other.actionToPerform;
            basicActionToPerform = other.basicActionToPerform;
            soundEffect          = other.soundEffect;

            cameraMovement = new CameraMovement(other.cameraMovement);
            slowMotion     = other.slowMotion;
            particleEvent  = other.particleEvent;
            forceEvent     = new Force(other.forceEvent, false);
            colorFlash     = other.colorFlash;
            ghostEffect    = other.ghostEffect;
            screenShake    = other.screenShake;
            tweenEvent     = other.tweenEvent;

            startTime = other.startTime;
            duration  = other.duration;
        }
Esempio n. 4
0
    /** Displays a foldout of a list of events */
    public Brawler.Event[] Display()
    {
        showFoldout = EditorGUILayout.Foldout(showFoldout, title + " (" + events.Length + ")");

        if (showFoldout)
        {
            EditorGUILayout.BeginVertical();
            {
                EditorGUI.indentLevel++;

                // Cycle through each event
                for (int i = 0; i < events.Length; i++)
                {
                    Brawler.Event e = events[i];

                    EditorGUILayout.BeginHorizontal();
                    {
                        e.type = (Brawler.EventType)EditorGUILayout.EnumPopup("Type:", e.type);
                        if (GUILayout.Button("X", GUILayout.Width(40)))
                        {
                            this.events           = ArrayUtils.RemoveAt <Brawler.Event> (this.events, i);
                            showStartTimeFoldouts = ArrayUtils.RemoveAt <bool>(showStartTimeFoldouts, i);
                            showDurationFoldouts  = ArrayUtils.RemoveAt <bool>(showDurationFoldouts, i);

                            continue;
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    if (e.type == Brawler.EventType.PerformAction)
                    {
                        // Select an action
                        e.actionToPerform = (ActionScriptableObject)EditorGUILayout.ObjectField("Action:", e.actionToPerform,
                                                                                                typeof(ActionScriptableObject), false);
                    }
                    else if (e.type == Brawler.EventType.PerformBasicAction)
                    {
                        // Select a basic action
                        e.basicActionToPerform = (BasicActionType)EditorGUILayout.EnumPopup("Basic action:", e.basicActionToPerform);
                    }
                    else if (e.type == Brawler.EventType.CameraMovement)
                    {
                        // Set the camera settings
                        e.cameraMovement.target = (TargetPosition)EditorGUILayout.EnumPopup("Target position:", e.cameraMovement.target);
                        if (e.cameraMovement.target == TargetPosition.CustomPosition)
                        {
                            e.cameraMovement.targetPosition = EditorGUILayout.Vector2Field("Position to move to:", e.cameraMovement.targetPosition);
                        }
                        e.cameraMovement.zoom        = EditorGUILayout.FloatField("Zoom:", e.cameraMovement.zoom);
                        e.cameraMovement.cameraSpeed = EditorGUILayout.FloatField("Camera speed:", e.cameraMovement.cameraSpeed);
                    }
                    else if (e.type == Brawler.EventType.SoundEffect)
                    {
                        // Select the sound effect to play when the event is triggered
                        e.soundEffect = (AudioClip)EditorGUILayout.ObjectField("Sound effect:", e.soundEffect, typeof(AudioClip), false);
                    }
                    else if (e.type == Brawler.EventType.SlowMotion)
                    {
                        e.slowMotion.timeScale = EditorGUILayout.Slider("Time scale:", e.slowMotion.timeScale, 0.001f, 1.0f);
                    }
                    else if (e.type == Brawler.EventType.ParticleEffect)
                    {
                        // Select a particle effect
                        e.particleEvent.effect     = (ParticleEffect)EditorGUILayout.EnumPopup("Particle Effect:", e.particleEvent.effect);
                        e.particleEvent.spawnPoint = (ParticleSpawnPoint)EditorGUILayout.EnumPopup("Spawn Point:", e.particleEvent.spawnPoint);
                        e.particleEvent.offset     = EditorGUILayout.Vector3Field("Offset:", e.particleEvent.offset);
                    }
                    else if (e.type == Brawler.EventType.Force)
                    {
                        Force force = e.forceEvent;

                        // Select a force type
                        force.forceType = (ForceType)EditorGUILayout.EnumPopup("Force Type:", force.forceType);
                        switch (force.forceType)
                        {
                        case ForceType.Velocity:
                            force.velocity = EditorGUILayout.Vector2Field("Velocity:", force.velocity);
                            force.relativeToFacingDirection = EditorGUILayout.Toggle("Relative to facing direction?", force.relativeToFacingDirection);
                            break;

                        case ForceType.Position:
                            force.target = (TargetPosition)EditorGUILayout.EnumPopup("Target Position:", force.target);
                            if (force.target == TargetPosition.CustomPosition)
                            {
                                force.customTargetPosition = EditorGUILayout.Vector2Field("Custom Position:", force.customTargetPosition);
                            }
                            force.faceTarget = EditorGUILayout.Toggle("Face target?", force.faceTarget);
                            break;
                        }
                    }
                    else if (e.type == Brawler.EventType.ColorFlash)
                    {
                        ColorFlash colorFlash = e.colorFlash;

                        // Edit the color-flashing event
                        colorFlash.color = EditorGUILayout.ColorField("Color:", colorFlash.color);

                        colorFlash.renderInFront = EditorGUILayout.Toggle("Render in front", colorFlash.renderInFront);
                    }
                    else if (e.type == Brawler.EventType.Ghosting)
                    {
                        GhostEffect ghostEffect = e.ghostEffect;

                        // Edit the ghosting effect
                        ghostEffect.color = EditorGUILayout.ColorField("Color:", ghostEffect.color);

                        ghostEffect.renderInFront = EditorGUILayout.Toggle("Render in front", ghostEffect.renderInFront);
                    }
                    else if (e.type == Brawler.EventType.ScreenShake)
                    {
                        ScreenShake screenShake = e.screenShake;

                        // Modify the screen shake settings
                        screenShake.speed     = EditorGUILayout.FloatField("Speed:", screenShake.speed);
                        screenShake.magnitude = EditorGUILayout.FloatField("Magnitude:", screenShake.magnitude);
                    }
                    else if (e.type == Brawler.EventType.Tween)
                    {
                        TweenEvent tweenEvent = e.tweenEvent;

                        TweenEventEditor(tweenEvent);
                    }

                    // Stores true if the event being edited requires a starting time to be specified
                    bool editStartTime = (e.type != Brawler.EventType.None);

                    // If we require to edit the duration
                    if (editStartTime)
                    {
                        // "Starting Time" foldout
                        showStartTimeFoldouts[i] = EditorGUILayout.Foldout(showStartTimeFoldouts[i], "Starting Time");

                        if (showStartTimeFoldouts[i])
                        {
                            ActionEditor.StartTimeFoldout(e.startTime);
                        }
                    }

                    // Stores true if the event being edited requires a 'duration' to be specified
                    bool editDuration = (e.type == Brawler.EventType.SlowMotion || e.type == Brawler.EventType.Force || e.type == Brawler.EventType.ColorFlash ||
                                         e.type == Brawler.EventType.FreezeAnimation || e.type == Brawler.EventType.ScreenShake || e.type == Brawler.EventType.Tween ||
                                         e.type == Brawler.EventType.Ghosting);

                    // If we require to edit the duration
                    if (editDuration)
                    {
                        // "Duration" foldout
                        showDurationFoldouts[i] = EditorGUILayout.Foldout(showDurationFoldouts[i], "Duration");

                        if (showDurationFoldouts[i])
                        {
                            ActionEditor.DurationFoldout(e.duration);
                        }
                    }

                    EditorGUILayout.Space();
                }

                // Add event ("+") button
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("");
                    // Add new event
                    if (GUILayout.Button("+", GUILayout.Width(40)))
                    {
                        this.events           = ArrayUtils.Add <Brawler.Event>(this.events, new Brawler.Event());
                        showStartTimeFoldouts = ArrayUtils.Add <bool>(showStartTimeFoldouts, false);
                        showDurationFoldouts  = ArrayUtils.Add <bool>(showDurationFoldouts, false);
                    }
                }
                EditorGUILayout.EndHorizontal();

                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndVertical();
        }

        // Return the modified array of events
        return(events);
    }
    private bool Flash()
    {
        if (!canThrowCube && currentCube != null && CubeCDTimer > 10)
        {
            if (delta_ThrowInteraction > 0)
            {
                FlashOver = false;
                Vector2 start = transform.position;

                // 什么都没有击中
                if (!currentCube.HitEnemy && !currentCube.HitInteractiveItem && !currentCube.HitGround)
                {
                    gameObject.transform.position = currentCube.gameObject.transform.position;
                    Destroy(currentCube.gameObject);
                    _rigidbody.velocity = Vector2.zero;
                }
                // 击中墙壁,自动跳起
                if (currentCube.HitGround)
                {
                    gameObject.transform.position = currentCube.HitGroundFlashPos;
                    CubeCDTimer         = 140;
                    _rigidbody.velocity = Vector2.zero;

                    // 先让unity进行碰撞判定,然后再进行跳跃
                    // Invoke("JumpAction", 0.1f);
                    JumpAction();

                    // 音效以及特效
                    playerSoundController.Play(PlayerSoundType.hit);
                    RefreshEffect.Play();

                    // 进入无敌帧
                    isInvincible = true;
                    Invoke("CancelInvincible", 0.04f);
                    Destroy(currentCube.gameObject);
                }
                // 击中敌人,自动跳起
                if (currentCube.HitEnemy)
                {
                    currentCube.target.GetComponent <EnemyUnit>().GetHurt(1);
                    gameObject.transform.position = currentCube.gameObject.transform.position;
                    CubeCDTimer         = 140;
                    _rigidbody.velocity = Vector2.zero;
                    JumpAction();

                    // 音效以及特效
                    playerSoundController.Play(PlayerSoundType.hit);
                    RefreshEffect.Play();

                    Destroy(currentCube.gameObject);
                }
                // 击中可交互物体
                if (currentCube.HitInteractiveItem)
                {
                    currentCube.InteractiveItem.GetComponent <InterActiveItem>().InterAction();
                    gameObject.transform.position = currentCube.gameObject.transform.position;
                    CubeCDTimer         = 140;
                    _rigidbody.velocity = Vector2.zero;
                    JumpAction();

                    // 音效以及特效
                    playerSoundController.Play(PlayerSoundType.hit);
                    RefreshEffect.Play();

                    Destroy(currentCube.gameObject);
                }

                // 音效
                playerSoundController.Play(PlayerSoundType.flash);
                // 残影特效
                GhostEffect ghostEffect = gameObject.GetComponent <GhostEffect>();
                if (ghostEffect != null)
                {
                    ghostEffect.DrawFlashGhost(start, gameObject.transform.position);
                }

                SecJump = false;
                return(true);
            }
        }
        if (delta_ThrowInteraction < 0)
        {
            FlashOver = true;
        }
        return(false);
    }