Esempio n. 1
0
    void Start()
    {
        objectManager = GameObject.FindGameObjectWithTag("GameManager");
        gameManager   = objectManager.GetComponent <GameManager>();
        gameManager.InitialisationPlayer();
        endLevel        = false;
        isDead          = false;
        shopDisabled    = false;
        lifeController  = gameObject.GetComponent <LifeController>();
        healthText      = GameObject.Find("HealthText").GetComponent <Text>();
        healthText.text = ": " + lifeController.GetLife() + " / " + lifeController.GetLifeMax();

        goldController = gameObject.GetComponent <GoldController>();
        CoinText       = GameObject.Find("CoinText").GetComponent <Text>();
        CoinText.text  = ": " + goldController.GetEnergy() + " / " + goldController.GetEnergyMax();

        // player's color is define in the inspector
        colorController = gameObject.GetComponent <ColorController>();
        if (colorController.GetColor() == 1)
        {
            this.GetComponent <SpriteRenderer>().color = new Color(0.4f, 0.4f, 1f, 1f);
        }
        else
        {
            this.GetComponent <SpriteRenderer>().color = new Color(1f, 0.4f, 0.4f, 1f);
        }
    }
Esempio n. 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ColorController cc      = new ColorController();
         Uri             myUri   = new Uri(Request.Url.ToString());
         string          ColorId = HttpUtility.ParseQueryString(myUri.Query).Get("ID");
         if (ColorId == null)
         {
             Response.Redirect("ListColors.aspx");
         }
         cc.GetColor(int.Parse(ColorId));
         Color.Text = cc.Color;
         if (cc.IsPublished == false)
         {
             IsPublished.Checked = false;
         }
         else
         {
             IsPublished.Checked = true;
         }
         LanguageController lc = new LanguageController();
         ddlLanguageId.DataSource     = lc.GetLanguages();
         ddlLanguageId.DataTextField  = "LanguageTitle";
         ddlLanguageId.DataValueField = "LanguageID";
         ddlLanguageId.DataBind();
         ddlLanguageId.SelectedValue = cc.LanguageID.ToString();
     }
 }
Esempio n. 3
0
 void Start()
 {
     colorController = gameObject.GetComponent <ColorController>();
     if (colorController.GetColor() == 1)
     {
         this.GetComponent <SpriteRenderer>().color = new Color(0.5f, 0.5f, 1f, 1f);
     }
     else
     {
         this.GetComponent <SpriteRenderer>().color = new Color(1f, 0.4f, 0.4f, 1f);
     }
     lifeController = gameObject.GetComponent <LifeController>();
 }
Esempio n. 4
0
 private void SwapColor()
 {
     if (Input.GetButtonDown("SwapColor"))
     {
         colorController.SwapColor();
         if (colorController.GetColor() == 1)
         {
             this.GetComponent <SpriteRenderer>().color = new Color(0.4f, 0.4f, 1f, 1f);
         }
         else
         {
             this.GetComponent <SpriteRenderer>().color = new Color(1f, 0.4f, 0.4f, 1f);
         }
     }
 }
Esempio n. 5
0
 //Check the collision between the melee collider and an object
 protected void SpecificCollision(LifeController lifeController, Collider2D col)
 {
     //When the Player attacks
     if (gameObject.GetComponentInParent <LifeController>().CompareTag("Player"))
     {
         Damage = GameObject.FindWithTag("Player").GetComponent <PlayerController>().GetDamageMelee();
         //If Player attacks an Enemy with melee attack
         if (lifeController != null && lifeController.CompareTag("Enemy"))
         {
             ColorController EnemyColor  = col.gameObject.GetComponent <ColorController>();
             ColorController PlayerColor = GameObject.FindWithTag("Player").GetComponent <ColorController>();
             //If the color is the same between Player & Enemy, melee attack works
             if (PlayerColor.SameColor(EnemyColor.GetColor()))
             {
                 GameObject go = Instantiate(ImpactFX, col.transform.position, transform.rotation) as GameObject;
                 lifeController.LoseLife(Damage);
             }
             else
             {
                 GameObject go = Instantiate(NoImpactFX, col.transform.position, transform.rotation) as GameObject;
             }
         }
     }
     //When an Enemy attacks
     else
     {
         Damage = gameObject.GetComponentInParent <Enemy>().damageMelee;
         //If Enemy attacks the Player with melee attack
         if (lifeController != null && lifeController.CompareTag("Player"))
         {
             ColorController EnemyColor  = gameObject.GetComponentInParent <ColorController>();
             ColorController PlayerColor = GameObject.FindWithTag("Player").GetComponent <ColorController>();
             //If the color is the same between Enemy & Player, melee attack works
             if (PlayerColor.SameColor(EnemyColor.GetColor()))
             {
                 GameObject go = Instantiate(ImpactFX, col.transform.position, transform.rotation) as GameObject;
                 lifeController.LoseLife(Damage);
             }
             else
             {
                 GameObject go = Instantiate(NoImpactFX, col.transform.position, transform.rotation) as GameObject;
             }
         }
     }
 }