Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        InventoryScript       playerInventory = collider.gameObject.GetComponent <InventoryScript> ();
        AnimationController2D animator        = door.GetComponent <AnimationController2D> ();

        if (playerInventory != null && door != null)
        {
            foreach (string keycard in playerInventory.inventory)
            {
                if (keycard.Equals(KeyToOpen))
                {
                    rend.color = Green;
                    if (animator != null)
                    {
                        animator.setAnimation("door open");
                    }
                    if (DoorOpen != null)
                    {
                        if (!played)
                        {
                            DoorOpen.Play();
                            played = true;
                        }
                    }
                    door.layer = LayerMask.NameToLayer("Default");
                }
            }
        }
    }
Exemplo n.º 2
0
    void Start()
    {
        rockScript = gameObject.GetComponent <RockScript>();
        animator   = gameObject.GetComponent <AnimationController2D>();
        rb2d       = GetComponent <Rigidbody2D>();
        sizeX      = transform.localScale.x;
        hasShot    = false;
        switch (shotType)
        {
        case "air":
            animator.setAnimation("mostlyBlank");
            break;

        case "water":
            animator.setAnimation("waterIdle");
            break;

        case "fire":
            animator.setAnimation("fireIdle");
            break;

        case "plasma":
            animator.setAnimation("plasmaIdle");
            break;
        }
    }
Exemplo n.º 3
0
 void Start()
 {
     Controller = gameObject.GetComponent <CharacterController2D>();
     mainCamera.GetComponent <CameraFollow2D>().startCameraFollow(this.gameObject);
     Animator    = gameObject.GetComponent <AnimationController2D> ();
     weapon      = this.gameObject.transform.GetChild(1);
     hasMomentum = false;
 }
Exemplo n.º 4
0
 public void CreateShot(PlayerController player)
 {
     if (cooldown <= 0)
     {
         cooldown = cooldownRate;
         if (fountainType.Equals("plasma"))
         {
             var shot = Instantiate(shotPrefab) as Transform;
             shot.position = transform.position;
             PlayerWeaponScript shotScript = shot.gameObject.GetComponent <PlayerWeaponScript>();
             player.weapon     = shotScript;
             shotScript.caster = player;
             shotScript.MoveToCaster();
         }
         if (fountainType.Equals("fire"))
         {
             var shot1 = Instantiate(shotPrefab) as Transform;
             var shot2 = Instantiate(shotPrefab) as Transform;
             var shot3 = Instantiate(shotPrefab) as Transform;
             shot1.position = shot2.position = shot3.position = transform.position;
             PlayerWeaponScript shotScript1 = shot1.gameObject.GetComponent <PlayerWeaponScript>();
             PlayerWeaponScript shotScript2 = shot2.gameObject.GetComponent <PlayerWeaponScript>();
             PlayerWeaponScript shotScript3 = shot3.gameObject.GetComponent <PlayerWeaponScript>();
             player.weapon = shotScript1;
             player.weapons.Push(shotScript2);
             player.weapons.Push(shotScript3);
             shotScript1.caster = shotScript2.caster = shotScript3.caster = player;
             //shotScript1.caster = player;
             //shotScript2.caster = player;
             //shotScript3.caster = player;
             shotScript1.MoveToCaster();
             shotScript2.MoveToCaster();
             shotScript3.MoveToCaster();
         }
         else if (fountainType.Equals("water"))
         {
             var shot = Instantiate(shotPrefab) as Transform;
             shot.position = transform.position;
             PlayerWeaponScript shotScript = shot.gameObject.GetComponent <PlayerWeaponScript>();
             player.weapon     = shotScript;
             shotScript.caster = player;
             shotScript.MoveToCaster();
             if (player.burning)
             {
                 player.burning = false;
                 Transform      burnParticles       = player.transform.GetChild(0);
                 ParticleSystem nbaJamOnFireEdition = burnParticles.GetComponent <ParticleSystem>();
                 nbaJamOnFireEdition.Stop();
                 Destroy(shotScript.gameObject);
             }
         }
         Transform      particles = transform.GetChild(0);
         ParticleSystem p         = particles.GetComponent <ParticleSystem>();
         p.Stop();
         AnimationController2D anim = GetComponent <AnimationController2D>();
         anim.setAnimation(fountainType + "Despawn");
     }
 }
Exemplo n.º 5
0
 void Start()
 {
     Controller = gameObject.GetComponent <CharacterController2D>();
     mainCamera.GetComponent <CameraFollow2D>().startCameraFollow(this.gameObject);
     Animator = gameObject.GetComponent <AnimationController2D> ();
     weapon   = this.gameObject.transform.GetChild(1);
     //weapon.GetComponent<SpriteRenderer> ();
     weaponRenderer = weapon.GetComponent <SpriteRenderer>();
 }
Exemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     _blastingZone   = gameObject.GetComponent(typeof(CircleCollider2D)) as CircleCollider2D;
     parent          = transform.parent.gameObject;
     _animator       = parent.GetComponent <AnimationController2D>();
     _animationTimer = _bombTime + 1.5f;
     _player         = GameObject.Find("Player").GetComponent(typeof(PlayerController)) as PlayerController;
     _source         = GetComponent <AudioSource>();
 }
Exemplo n.º 7
0
    // Use this for initialization
    protected void Start()
    {
        _animator = new AnimationController2D(GetComponent <SpriteRenderer>(), new Animation2D(sprite, 1, "sprite", true, loop, animFadeOut));
        GetComponent <SpriteRenderer>().sortingLayerName = "Ground";
        //create a multicollider via the polygon collider array
        _multiCollider = new MultiCollider2D(colliderList);
        _audioSource   = GetComponent <AudioSource>();
        //Set all the colliders to triggers, as a hazard, we dont to have any physics or interact with physics dyrectly, if gravity of physics is applicable ulter the rigidbody of the gameOb
        foreach (PolygonCollider2D collider in _multiCollider.colliders)
        {
            collider.isTrigger = true;
        }

        //Create the meshholder object and attach it as a child, it holds just the mesh renderer and the mesh filter. and is fed the shape from our colliders
        meshHolder = new GameObject();
        meshHolder.transform.position   = transform.position;
        meshHolder.transform.rotation   = transform.rotation;
        meshHolder.transform.localScale = transform.localScale;
        //Attach the object as a child

        meshHolder.transform.parent = gameObject.transform;
        //Add mesh renderer component
        meshHolder.AddComponent <MeshRenderer>();
        meshHolder.AddComponent <MeshFilter>();
        //Finally set out pointer to the meshfilter to the one now attached to the child gameobject
        meshFilter = GetComponentInChildren <MeshFilter>();

        //grab point set form the first hitbox
        currentPointCount = _multiCollider.GetActiveCollider().GetTotalPointCount();

        Mesh mesh = new Mesh();

        Vector2[] points   = _multiCollider.GetActiveCollider().points;
        Vector3[] vertices = new Vector3[currentPointCount];
        for (int j = 0; j < currentPointCount; j++)
        {
            Vector2 actual = points[j];
            vertices[j] = new Vector3(actual.x, actual.y, gameObject.transform.position.z);
        }
        Triangulator tr = new Triangulator(points);

        int[] triangles = tr.Triangulate();
        mesh.vertices  = vertices;
        mesh.triangles = triangles;
        if (showColliders)
        {
            meshFilter.mesh = mesh;
        }
        else
        {
            meshFilter.mesh = null;
        }
        _animator.currAnim.paused = false;
    }
Exemplo n.º 8
0
    // Use this for initialization upon activation of the script
    virtual protected void Start()
    {
        health     = maxHealth;
        tempHealth = health;

        GenerateAnimationList();
        //If the animator isnt already defined just make one
        animator = new AnimationController2D(_renderer, animationList);

        //Ignore collisions
        Physics2D.IgnoreLayerCollision(LayerMask.NameToLayer("Default"), LayerMask.NameToLayer("Default"));
    }
Exemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        _levelManager = GameObject.Find("GameManagers").GetComponent <GameManager>();

        _levelManager.AddKeyEnemy();
        _animator      = GetComponent <AnimationController2D>();
        _collider      = GetComponent <Collider2D>();
        gameObject.tag = "Crow";

        _source = GetComponent <AudioSource>();
        _source.Play();
    }
Exemplo n.º 10
0
 // Use this for initialization
 void Start()
 {
     airCooldown = 0;
     health      = gameObject.GetComponent <HealthScript>();
     _controller = gameObject.GetComponent <CharacterController2D>();
     _animator   = gameObject.GetComponent <AnimationController2D>();
     colorChange = gameObject.GetComponent <SpriteRenderer> ();
     baseColor   = colorChange.color;
     weapons     = new Stack();
     audioPlayer = GetComponent <AudioSource>();
     sounds      = GetComponent <Sounds>();
 }
Exemplo n.º 11
0
 void Update()
 {
     if (cooldown > 0)
     {
         cooldown -= Time.deltaTime;
         if (cooldown <= 0)
         {
             Transform      particles = transform.GetChild(0);
             ParticleSystem p         = particles.GetComponent <ParticleSystem>();
             p.Play();
             AnimationController2D anim = GetComponent <AnimationController2D>();
             anim.setAnimation(fountainType + "Norm");
         }
     }
 }
Exemplo n.º 12
0
    // Use this for initialization
    void Start()
    {
        _animator   = gameObject.GetComponent <AnimationController2D>();
        _controller = gameObject.GetComponent <CharacterController2D>();

        startingPatrolPoint = this.transform.position;
        endingPatrolPoint   = startingPatrolPoint + patrolDelta;

        minChasePoint = startingPatrolPoint - deltaNegChase;
        maxChasePoint = startingPatrolPoint + deltaPosChase;

        turnTime += rovingPauseTime;

        _source = GetComponent <AudioSource>();
        _source.Play();
    }
    void Start()
    {
        shield      = GameObject.FindGameObjectWithTag("Shield");
        sword       = GameObject.FindGameObjectWithTag("Sword");
        coll        = GameObject.FindGameObjectWithTag("Player").GetComponent <BoxCollider2D> ();
        enemy       = GameObject.FindGameObjectWithTag("Enemy").GetComponent <BoxCollider2D> ();
        _controller = gameObject.GetComponent <CharacterController2D>();
        _animator   = gameObject.GetComponent <AnimationController2D>();

        gameCamera.GetComponent <CameraFollow2D> ().startCameraFollow(this.gameObject);
        winPanel.SetActive(false);
        gameOverPanel.SetActive(false);
        pausePanel.SetActive(false);
        currHealth = health;
        _animator.setAnimation("Fall");
    }
Exemplo n.º 14
0
    // Use this for initialization
    void Start()
    {
        _currentState = playerState.FREE;
        // TODO: Discover a more efficient way to find the below game object
        // I made it worse, but this was to ensure enstantiation of the brain on startup.
        //  I don't think there will be horrible performance issues. -JW
        if (GameObject.Find("TheBrain") != null)
        {
            brain = GameObject.Find("TheBrain").GetComponent <TheBrain>();
        }
        else
        {
            Debug.Log("The Brain was not found for this object");
            brain = new TheBrain();

            brain.Time         = float.PositiveInfinity;
            brain.PlayersMoney = 100;
            brain.InitalizePlayerItemCount();
            brain.InitalizePlayerIncenseCount();
            brain.currIncense = TheBrain.IncenseTypes.Base;

            debugMode = true;
        }

        _controller = gameObject.GetComponent <CharacterController2D>();
        _animator   = gameObject.GetComponent <AnimationController2D>();
        gameCamera.GetComponent <CameraFollow2D>().startCameraFollow(this.gameObject);

        _invincibilitySprite = GameObject.Find("Invincible");
        _invincibilitySprite.SetActive(false);

        TimeInitialization();

        BankAccount.AddToBank(brain.PlayersMoney);
        _prevY = gameObject.transform.position.y;

        _playerCollider = gameObject.GetComponent <BoxCollider2D>();

        _source = GetComponent <AudioSource>();
        _source.Play();
    }
    public override void OnInspectorGUI()
    {
        if (myController == null)
        {
            myController = (AnimationController2D)target;
        }

        if (animationClips == null)
        {
            var arr = myController.animator.runtimeAnimatorController.animationClips;
            if (arr != null)
            {
                animationClips = arr.ToList();
            }
        }

        if (animationClips == null || animationClips.Count == 0)
        {
            EditorGUILayout.LabelField("No animation clips found on this controller");
            return;
        }

        string[] animationClipsNames = animationClips.Select(c => c.name).ToArray();

        Type          myType       = myController.GetType();
        var           methodsInfo  = myType.GetMethods(BindingFlags.Public | BindingFlags.Instance);
        List <String> methodsNames = methodsInfo.ToList().Select(elm => elm.Name).ToList();

        foreach (AnimationEffect effect in myController.effects)
        {
            effect.fold = EditorGUILayout.Foldout(effect.fold, effect.targetAnimationClip.name + " // " + effect.methodName);

            if (effect.fold)
            {
                effect.selectedParameterType = (AnimationEffect.parameterType)EditorGUILayout.EnumPopup("Parameter type", effect.selectedParameterType);

                switch (effect.selectedParameterType)
                {
                case AnimationEffect.parameterType.OBJECT:
                    var prefab = EditorGUILayout.ObjectField(effect.objectValue, typeof(GameObject)) as GameObject;
                    effect.objectValue = prefab;
                    break;

                case AnimationEffect.parameterType.BOOLEAN:
                    var boolValue = EditorGUILayout.Toggle(effect.booleanValue == -1 ? false : true) == true ? 1 : -1;
                    effect.booleanValue = boolValue;
                    break;

                case AnimationEffect.parameterType.FLOAT:
                    var floatValue = EditorGUILayout.FloatField(effect.floatValue);
                    effect.floatValue = floatValue;
                    break;
                }

                if (effect.targetAnimationClip != null)
                {
                    int index             = animationClips.FindIndex(c => c.name == effect.targetAnimationClip.name);
                    var selectedClipIndex = EditorGUILayout.Popup(index, animationClipsNames);
                    if (animationClips[selectedClipIndex] != effect.targetAnimationClip)
                    {
                        effect.targetAnimationClip = animationClips[selectedClipIndex];
                        return;
                    }

                    int methodNameIndex     = !String.IsNullOrEmpty(effect.methodName) ? methodsNames.FindIndex(m => m == effect.methodName) : 0;
                    var selectedMethodIndex = EditorGUILayout.Popup(methodNameIndex, methodsNames.ToArray());
                    if (methodsNames[selectedMethodIndex] != effect.methodName)
                    {
                        effect.methodName = methodsNames[selectedMethodIndex];
                        return;
                    }
                }
                else
                {
                    effect.targetAnimationClip = animationClips.FirstOrDefault();
                    return;
                }


                var frameToPlayIn = EditorGUILayout.IntField("Frame to play in", effect.frameToPlayIn);

                effect.frameToPlayIn = frameToPlayIn;

                if (GUILayout.Button("Remove"))
                {
                    myController.effects.Remove(effect);
                    return;
                }
                GUILayout.Space(5);
            }
        }

        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("Add effect"))
        {
            myController.effects.Add(new AnimationEffect()
            {
                targetAnimationClip   = animationClips.FirstOrDefault(),
                methodName            = methodsNames.FirstOrDefault(),
                selectedParameterType = AnimationEffect.parameterType.OBJECT
            });
        }

        if (GUILayout.Button("Set animation effects"))
        {
            myController.SetAnimationEffects();
        }

        EditorGUILayout.EndHorizontal();

        if (GUILayout.Button("Clear all effects"))
        {
            myController.ClearAllAnimationEffects();
        }
    }
Exemplo n.º 16
0
    // Use this for initialization
    void Start()
    {
        if (GameObject.Find("TheBrain") != null)
        {
            brain = GameObject.Find("TheBrain").GetComponent <TheBrain>();
        }
        else
        {
            Debug.Log("The Brain was not found for this object");
            brain = new TheBrain();

            brain.Time         = float.PositiveInfinity;
            brain.PlayersMoney = 100;
            brain.InitalizePlayerItemCount();
            brain.InitalizePlayerIncenseCount();
            brain.currIncense = TheBrain.IncenseTypes.Base;
        }

        player = GameObject.Find("Player").GetComponent <PlayerController>();

        _animator = GetComponent <AnimationController2D>();
        cart      = new ShoppingCart();

        BombCount.text          = cart.GetNumOfSpecificItem(TheBrain.ItemTypes.Bomb).ToString();
        InvincibilityCount.text = cart.GetNumOfSpecificItem(TheBrain.ItemTypes.Invincible).ToString();

        BombPricing.text          = (10 * cart.GetNumOfSpecificItem(TheBrain.ItemTypes.Bomb)).ToString();
        InvincibilityPricing.text = (10 * cart.GetNumOfSpecificItem(TheBrain.ItemTypes.Invincible)).ToString();

        TotalCount.text   = cart.GetTotalSizeOfCart().ToString();
        TotalPricing.text = player.BankAccount.TotalWithdrawalAmount.ToString();

        Sprite currIncense;

        if (brain.currIncense != TheBrain.IncenseTypes.None)
        {
            currIncense = brain.IncenseSprites[(int)brain.currIncense];
        }
        else
        {
            currIncense = brain.IncenseSprites[0];
        }


        //conversionTimer = new TimerController(brain.TotalTime, currIncense,
        //                                    currentTimeConversionBar, conversionTimerText);

        //conversionTimer.ReduceTimer((brain.TotalTime - brain.Time) * 60);

        prevValue = currentTimeConversionBar.value = maxSliderValue = (brain.Time / (brain.TotalTime));

        float conversionCalc = 5 + (7 * (9 - (10 * (brain.Time / (brain.TotalTime)))));

        float barX = (conversionCalc > 0) ? conversionCalc : 0;

        subtractedConversionBar.rectTransform.offsetMax = new Vector2(-barX, subtractedConversionBar.rectTransform.offsetMax.y);

        double minutes = brain.Time;             //Divide the guiTime by sixty to get the minutes.
        double seconds = (brain.Time * 60) % 60; //Use the euclidean division for the seconds

        conversionTimerText.text = string.Format("{0:00} : {1:00}", Math.Floor(minutes), Math.Floor(seconds));
    }
Exemplo n.º 17
0
 // Use this for initialization
 void Start()
 {
     player  = gameObject.GetComponent <Rigidbody2D>();
     animate = gameObject.GetComponent <AnimationController2D>();
 }
Exemplo n.º 18
0
 void Start()
 {
     anim = this.gameObject.GetComponent <AnimationController2D>();
 }
Exemplo n.º 19
0
    // Use this for initialization
    void Start()
    {
        gameCamera.GetComponent<CameraFollow2D>().startCameraFollow();
        _controller = gameObject.GetComponent<CharacterController2D>();
        _animator = gameObject.GetComponent<AnimationController2D>();

        currentHealth = maxHealth;
    }
Exemplo n.º 20
0
 void Start()
 {
     _controller = gameObject.GetComponent<CharacterController2D>();
     _animator = gameObject.GetComponent<AnimationController2D>();
     currentHealth = health;
     cameraDerp = true;
     StartCoroutine("FadeInSequence");
     music = GameObject.Find("GameManager").GetComponent<AudioSource>();
 }
Exemplo n.º 21
0
 // Use this for initialization
 void Start()
 {
     player  = gameObject.GetComponent <CharacterController>();
     animate = gameObject.GetComponent <AnimationController2D>();
 }
Exemplo n.º 22
0
    // Use this for initialization
    void Start()
    {
        _controller = gameObject.GetComponent<CharacterController2D>();
        _animator = gameObject.GetComponent<AnimationController2D>();
        paused = false;

        //Gather audio sources and set the private variables
        AudioSource[] sources = this.GetComponents<AudioSource>();
        if(hardFloor)
        {
            walkClip = sources[4];
        }
        else
        {
            walkClip = sources[0];
        }

        jumpClip = sources[2];
        hurtClip = sources[1];
        levelClip = sources[3];
        ladderClip = sources[5];
        gameoverClip = sources[6];

        playingClimb = false;

        currentHealth = maxHealth;

        playerHolding = null;
        nearbyObject = null;
        invincible = false;
        onLadder = false;
        nearLadder = false;
        if(PlayerPrefs.GetInt("Checkpoint") == 1)
        {
            this.transform.position = new Vector2(PlayerPrefs.GetFloat("xPosition"), PlayerPrefs.GetFloat("yPosition"));
        }
        walkWait = 0;
    }
Exemplo n.º 23
0
 void Start()
 {
     _animator = gameObject.GetComponent<AnimationController2D>();
     animTimer = Random.Range(0, animationLength);
 }
Exemplo n.º 24
0
    // Use this for initialization
    void Start()
    {
        _controller = gameObject.GetComponent<CharacterController2D>();
        _animator = gameObject.GetComponent<AnimationController2D>();
        currentHealth = maxHealth;

        playerHolding = null;
        nearbyObject = null;
    }
Exemplo n.º 25
0
    void Start()
    {
        if (GameObject.Find("Player") != null)
        {
            player = GameObject.Find("Player");
        }
        else
        {
            player = GameObject.Find("DarkPlayer");
        }

        boss = GameObject.Find("Boss");

        _animator = gameObject.GetComponent<AnimationController2D>();

        destinations = new Vector3[positions.Length + 1];
        destinations[0] = transform.position;
        for(int i = 0; i < positions.Length; i++)
        {
            destinations[i + 1] = positions[i].transform.position;
            maxPositions++;

        }

        if(tier2)
        {
            GetComponent<MovingEye>().enabled = true;
        }
        else
        {
            GetComponent<MovingEye>().enabled = false;
        }

        animTimer = Random.Range(0, animationLength);
    }
Exemplo n.º 26
0
 // Use this for initialization
 void Start()
 {
     _body     = gameObject.GetComponent <CharacterController2D>();
     _animator = gameObject.GetComponent <AnimationController2D>();
     gameCamera.GetComponent <CameraFollow2D>().startCameraFollow(gameObject);
 }