void OnTriggerEnter2D(Collider2D other)
    {
        Tds_Tile vTile = other.GetComponent <Tds_Tile> ();

        if (vTile != null)
        {
            if (vTile.vTileType == Tds_Tile.cTileType.Destructible)
            {
                vTile.TileDie();
            }

            if (vTile.vTileType == Tds_Tile.cTileType.Wall && vRebounce <= 0)
            {
                ProjDie();
            }
            else if (vTile.vTileType == Tds_Tile.cTileType.Wall)
            {
                CalculateRebounce(other);
            }
        }
        else if (other.tag == "Character")
        {
            Tds_Character vChar = other.GetComponent <Tds_Character> ();

            //make sure the projectile is for the other faction and the target is alive.
            if (vChar.vFactionType != vProjFactionType && vChar.IsAlive)
            {
                vChar.ApplyDamage(vDmg);
                ProjDie();
            }
        }
    }
    void InitialiseGame()
    {
        //every character need a spriterenderer by default
        vSpriteMat = GetComponent <SpriteRenderer>().material;
        //get back the default material
        vBlinkMat = (Material)Resources.Load("Components/DroidSansMono", typeof(Material));        //get this material which make the sprite white

        //disable the gameover obj when the game start.
        if (vGameOverObj != null)
        {
            vGameOverObj.SetActive(false);
        }

        //disable the vPressSpaceObj obj when the game start.
        if (vPressSpaceObj != null)
        {
            vPressSpaceObj.SetActive(false);
        }

        vAudioSource = GetComponent <AudioSource>();

        //we hide the Mouse Icon completely
        if (AimObj != null)
        {
            Cursor.visible = false;
        }

        //initialise every character
        foreach (Tds_Character vChar in Resources.FindObjectsOfTypeAll <Tds_Character>())
        {
            if (vChar.IsCharacter)
            {
                //get the main player
                if (vChar.IsPlayer)
                {
                    vMainPlayer = vChar;
                }

                if (vChar.IsPlayer2)
                {
                    vPlayer2 = vChar;
                }
                //initialise the character
                vChar.InitialiseChar(this);
            }
        }
        //game is ready
        IsReady = true;
    }
Exemple #3
0
    void Start()
    {
        CanBeSeen = true;

        //check if it's animated or not
        IsAnimated = false;

        //get the renderer automatically
        vRenderer = GetComponent <SpriteRenderer> ();

        if (vAnimationList.Count > 0)
        {
            //initialise the sprite list to be used
            vAnimationSprite = new List <Sprite>();

            //create 1 time the sprite list to be used after
            foreach (Texture2D vCurText in vAnimationList)
            {
                vAnimationSprite.Add(Sprite.Create(vCurText, vRenderer.sprite.rect, new Vector2(0f, 0f), 128f));
            }

            IsAnimated = true;
        }

        if (vTileType == cTileType.Destructible)
        {
            vGameManager = GameObject.Find("GameManager").GetComponent <Tds_GameManager> ();

            //change it transform.Z to be near the camera so the Mouseover, mouseenter and mouseexit are trigged before everthing else
            Vector3 vPosition = transform.position;
            vPosition.z = -2f;
            gameObject.transform.position = vPosition;
        }

        IsReady = true;

        if (vTileType == cTileType.Trap)
        {
            //get the main player
            vMainPlayer = GameObject.Find("Player").GetComponent <Tds_Character>();

            InvokeRepeating("ActivateTrap", 0f, AnimationSpeed);
        }
        else if (IsAnimated)
        {
            InvokeRepeating("AnimateTile", 0f, AnimationSpeed);
        }
    }
Exemple #4
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit2D hit = Physics2D.Raycast(transform.position, transform.up);

        if (hit.transform.tag == "Character")
        {
            Tds_Character Char = hit.transform.gameObject.GetComponent <Tds_Character>();
            if (Char.IsAlive && timecounter >= 1)
            {
                Char.ApplyDamage(1);
                timecounter = 0;
            }
            timecounter += Time.deltaTime;
        }
        else
        {
            timecounter = 1;
        }
        LazerRender.SetPosition(0, transform.position);
        LazerRender.SetPosition(1, hit.point);
    }
Exemple #5
0
    IEnumerator OnTriggerEnter2D(Collider2D other)
    {
        Tds_Tile vTile = other.GetComponent <Tds_Tile>();

        if (vTile != null || other.tag == "Ball")
        {
            if (vTile != null && vTile.vTileType == Tds_Tile.cTileType.Destructible)
            {
                vTile.TileDie();
            }

            if (((vTile != null && vTile.vTileType == Tds_Tile.cTileType.Wall) || other.tag == "Ball") && vRebounce <= 0)
            {
                this.vCollider.isTrigger = false;
                yield return(new WaitForSeconds(0.02f));

                ProjDie();
            }
            else if ((vTile != null && vTile.vTileType == Tds_Tile.cTileType.Wall) || other.tag == "Ball")
            {
                this.vCollider.isTrigger = false;
                yield return(new WaitForSeconds(0.02f));

                CalculateRebounce(other);
            }
        }
        else if (other.tag == "Character")
        {
            Tds_Character vChar = other.GetComponent <Tds_Character>();

            //make sure the projectile is for the other faction and the target is alive.
            if (vChar.vFactionType != vProjFactionType && vChar.IsAlive)
            {
                vChar.ApplyDamage(vDmg);
                ProjDie();
            }
        }
    }
Exemple #6
0
 // Use this for initialization
 void Start()
 {
     vCurCharacter = transform.parent.GetComponent <Tds_Character>();
     vGameManager  = GameObject.Find("GameManager").GetComponent <Tds_GameManager>();
     vAudioSource  = GetComponent <AudioSource>();
 }
 // Use this for initialization
 void Start()
 {
     //get the player once to be able to update just when we have NEW collider
     //we will refresh the ground type, and other conditions on the player ONLY when we make changement
     vCharacter = transform.parent.parent.GetComponent <Tds_Character>();
 }