// Use this for initialization
    void Start()
    {
        selectedCharacter = UnityEngine.Random.Range(1, 5);
        joystickCounter   = selectedCharacter;
        offset            = new Vector2((1 / numberOfCharacters) * selectedCharacter, 0);
        offset_temp       = new Vector2((1 / numberOfCharacters) * selectedCharacter, 0);
        scale_temp        = new Vector2((1 / numberOfCharacters), 1);
        startPos          = gameObject.transform.position;

        playerIndexInt = GamePad.IndexToInt(player);

        sprite = gameObject.renderer.material;
        sprite.mainTexture.wrapMode = TextureWrapMode.Repeat;
        sprite.mainTextureOffset    = offset;
        sprite.mainTextureScale     = scale;

        colorFlash   = gameObject.GetComponent <ColorFlash>();
        selectButton = Instantiate(Resources.Load("Prefabs/Screens/MenuScreen/Character_Select_SelectButton"), new Vector3(transform.position.x, transform.position.y, -.5f), Quaternion.identity) as GameObject;
        selectButton.transform.parent = gameObject.transform.parent;
        selectButton.SetActive(false);

        useMPU = GameObject.FindGameObjectWithTag("Global").GetComponent <MenuToGame>().mpus[playerIndexInt - 1];

        if (useMPU)
        {
            tempCom       = gameObject.transform.parent.GetComponent <COMParser>().com;
            mpuController = gameObject.AddComponent <MPUController>();
            mpuController.controllerNumber = playerIndexInt;
        }

        Invoke("AddPlayerCharacter", 0.01f);
    }
    // Use this for initialization
    void Start()
    {
        selectedCharacter = UnityEngine.Random.Range(1, 5);
        joystickCounter = selectedCharacter;
        offset = new Vector2((1 / numberOfCharacters) * selectedCharacter, 0);
        offset_temp = new Vector2((1 / numberOfCharacters) * selectedCharacter, 0);
        scale_temp = new Vector2((1 / numberOfCharacters), 1);
        startPos = gameObject.transform.position;

        playerIndexInt = GamePad.IndexToInt(player);

        sprite = gameObject.renderer.material;
        sprite.mainTexture.wrapMode = TextureWrapMode.Repeat;
        sprite.mainTextureOffset = offset;
        sprite.mainTextureScale = scale;

        colorFlash = gameObject.GetComponent<ColorFlash>();
        selectButton = Instantiate(Resources.Load("Prefabs/Screens/MenuScreen/Character_Select_SelectButton"), new Vector3(transform.position.x, transform.position.y, -.5f), Quaternion.identity) as GameObject;
        selectButton.transform.parent = gameObject.transform.parent;
        selectButton.SetActive(false);

        useMPU = GameObject.FindGameObjectWithTag("Global").GetComponent<MenuToGame>().mpus[playerIndexInt - 1];

        if (useMPU)
        {
            tempCom = gameObject.transform.parent.GetComponent<COMParser>().com;
            mpuController = gameObject.AddComponent<MPUController>();
            mpuController.controllerNumber = playerIndexInt;
        }

        Invoke("AddPlayerCharacter", 0.01f);
    }
Exemplo n.º 3
0
 void Start()
 {
     explosion = transform.Find("explosion").GetComponent <ParticleSystem>();
     anim      = GetComponent <Animator>();
     Audio     = GetComponent <AudioSource>();
     sprite    = GetComponent <SpriteRenderer>();
     PlayerPrefs.SetInt("Score", 0);
     flashController          = GetComponent <ColorFlash>();
     flashController.Duration = invincibilityTime;
     flashController.Speed    = invincibilityPulseSpeed;
     flashController.Color    = damageColor;
 }
Exemplo n.º 4
0
 private void Start()
 {
     player          = FindObjectOfType <Player>();
     spr             = gameObject.GetComponent <SpriteRenderer>();
     audio           = gameObject.GetComponent <AudioSource>();
     collider        = gameObject.GetComponent <Collider2D>();
     animator        = gameObject.GetComponent <Animator>();
     flashController = gameObject.GetComponent <ColorFlash>();
     if (remainingHealth == 0)
     {
         remainingHealth = StartingHealth;
     }
     isDead = false;
 }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        hitBox        = gameObject.GetComponent <Collider2D>();
        hangers       = gameObject.GetComponentsInChildren <HangerBaySpawn>();
        player        = FindObjectOfType <Player>();
        myColorFlash  = gameObject.GetComponent <ColorFlash>();
        lastSpawn     = spawnTimer;
        lastFlash     = timeBetweenFlashes;
        isDead        = false;
        startPosition = transform.position;
    }
Exemplo n.º 7
0
    void Start()
    {
        top_animator    = Global.getChildGameObject(gameObject, "Animation_top").GetComponent <Animator>();
        bottom_animator = Global.getChildGameObject(gameObject, "Animation_bottom").GetComponent <Animator>();

        mainCamera = GameObject.FindGameObjectWithTag("MainCamera");
        colorFlash = GetComponent <ColorFlash>();

        gamePadIndex     = GamePad.Index.One;
        Direction        = Facing.RIGHT;
        move             = Vector2.zero;
        maxVelocity      = new Vector2(5, 3);
        maxKnockback     = new Vector2(700, 2);
        damageMultiplier = 1f;
        dontMove         = false;

        maxHealth = 10;
        health    = maxHealth;
        isDead    = false;
    }
Exemplo n.º 8
0
    // Use this for initialization
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        hitBox             = gameObject.GetComponent <Collider2D>();
        myColorFlash       = gameObject.GetComponent <ColorFlash>();
        hangers            = gameObject.GetComponentsInChildren <HangerBaySpawn>();
        player             = FindObjectOfType <Player>();
        flashOutTimePlayed = transitionOutFlashAmount;
        flashInTimePlayed  = transitionInFlashAmount;
        lastFlashTime      = timeBetweenFlashes;
        lastSpawn          = spawnTimer;
        isDead             = false;
    }
Exemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        myRGB2D            = gameObject.GetComponent <Rigidbody2D>();
        hitBox             = gameObject.GetComponent <Collider2D>();
        player             = FindObjectOfType <Player>();
        lastMoveTime       = timeBetweenMoves;
        reachedDestination = true;
        myColorFlash       = gameObject.GetComponent <ColorFlash>();
        flashInTimePlayed  = transitionInFlashAmount;
        flashOutTimePlayed = transitionOutFlashAmount;
        lastFlashTime      = timeBetweenFlashes;
        isDead             = false;
    }
Exemplo n.º 10
0
 public void Update()
 {
     if (!OnFlash)
     {
         material.SetColor("_Color", ColorByHealth.Evaluate(health.healthRate));
     }
     else
     {
         timer += Time.deltaTime;
         material.SetColor("_Color", ColorFlash.Evaluate(timer / FlashTime));
         if (timer >= FlashTime)
         {
             OnFlash = false;
             timer   = 0f;
         }
     }
     hp = health.healthRate;
     if (hp == 0 || block == null)
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 11
0
    void Start()
    {
        leftWall   = GameObject.FindGameObjectWithTag("Left Wall").GetComponent <BreakableWall>();
        rightWall  = GameObject.FindGameObjectWithTag("Right Wall").GetComponent <BreakableWall>();
        topWall    = GameObject.FindGameObjectWithTag("Top Wall").GetComponent <ColorFlash>();
        bottomWall = GameObject.FindGameObjectWithTag("Bottom Wall").GetComponent <ColorFlash>();

        soundManager = GameObject.FindObjectOfType <SoundManager> ();
        canvas       = GameObject.FindObjectOfType <Canvas>();

        text = canvas.GetComponentInChildren <Text> ();

        leftPlayer  = Instantiate(leftPlayer, new Vector3(-6, 0, 0), Quaternion.identity);
        rightPlayer = Instantiate(rightPlayer, new Vector3(6, 0, 0), Quaternion.identity);

        puck = Instantiate(puck, Vector3.zero, Quaternion.identity);

        puck.Initialize();

        StartCoroutine(puck.ResetPosition());
        StartCoroutine(Countdown());
    }
Exemplo n.º 12
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);
    }
Exemplo n.º 13
0
 // Use this for initialization
 void Start()
 {
     this._levelController = GameObject.FindObjectOfType<LevelController>();
     this._fader = this.GetComponent<Fader>();
     this._collider = this.GetComponent<Collider2D>();
     this._renderer = this.GetComponent<Renderer>();
     this.state = TargetState.UNHIT;
     this._rotater = GetComponent<Rotater>();
     if (!this._rotater) this._rotater = this.gameObject.AddComponent<Rotater>(); //testing
     this._originalRotation = this.transform.rotation;
     _missiles = this.GetComponentsInChildren<Missile>();
     _flash = Camera.main.GetComponent<ColorFlash>();
 }