Inheritance: MonoBehaviour
Exemple #1
0
 public override void OnCharacterDestroySuccess(CharacterScript destroyedCharacter)
 {
     base.OnCharacterDestroySuccess(destroyedCharacter);
     int scoreToAdd = (int)(destroyedCharacter.pointsForDestroying * multiplier);
     score += scoreToAdd;
     setMaxTurrets(maxTurretIdx + 1);
 }
Exemple #2
0
 public AbilityScript(CharacterScript attachedPlayer)
 {
     abilityName = "No Name";
     tooltipText = "No Tooltip Text";
     staminaCost = 0;
     player = attachedPlayer;
 }
Exemple #3
0
	void Start(){
		
		this.character = GameObject.FindGameObjectWithTag ("Player");
		this.cs = this.character.GetComponent<CharacterScript> ();
		inventory = GameObject.FindGameObjectWithTag ("Inventory").GetComponent<InventoryScript> ();

	}
    private HealthScript healthScript; // Health of character taking dmg

    #endregion Fields

    #region Methods

    void Start()
    {
        // Damage should have a '-' in front of it, heals a '+'
        switch(dmgType) {
        case dmgTypes.Damage:
            // Set actual dmg number
            guiText.text = "-" + amount.ToString();
            break;
        case dmgTypes.Heal:
            // Set actual heal number
            guiText.text = "+" + amount.ToString();
            break;
        }

        // Setup visual styling
        guiText.material.color = color; // set text color

        character = transform.parent.GetComponent<CharacterScript>();
        if(character) {
            // spawn health bubble where character taking dmg starts
            transform.position = Camera.main.WorldToViewportPoint(character.transform.position);
        }

        Destroy(gameObject, duration);	// Only shows up for a short period of time
    }
	// Use this for initialization
	void Awake () {
		//print (PlayerPrefs.GetString("Difficult"));
		// --- LOAD RESOURCES TO CHARACTER ---
		//this.prefab = Resources.Load<GameObject>("Prefabs/MainCharacters/Level02/hombre_lvl2");
		this.prefab = Resources.Load<GameObject>("Prefabs/MainCharacters/Level02/"+PlayerPrefs.GetString("Player")+"_lvl2");
		this.character = Instantiate (prefab, respawn.transform.position, prefab.transform.rotation) as GameObject;
		this.cs = this.character.GetComponent<CharacterScript> ();
		this.cm = this.character.GetComponent<ClickToMove_lvl2> ();

		this.invent = this.character.GetComponentInChildren <InventoryScript> ();
		this.map = GameObject.FindGameObjectWithTag ("Minimap").GetComponent<miniMapLv2> ();
		this.music = GameObject.FindGameObjectWithTag ("music_engine").GetComponent<Music_Engine_Script> ();

		// Memory Card Save/Load data
		this.mc = GameObject.FindGameObjectWithTag ("MemoryCard").GetComponent<MemoryCard> ();
		this.save = this.mc.saveData();
		this.load = this.mc.loadData();
		time_play = this.load.loadTimePlayed ();


		// --- LOAD RESOURCES TO MENU ---
		gui = new PauseMenuGUI();
		gui.initResources ();
		
		
		this.c = this.ambientLight.light.color;

	}
Exemple #6
0
 public DefendScript(CharacterScript attachedPlayer)
     : base(attachedPlayer)
 {
     abilityName = "Defend";
     tooltipText = "Prepare your unit to defend incoming damage";
     staminaCost = 2;
 }
Exemple #7
0
 public StompScript(CharacterScript attachedPlayer)
     : base(attachedPlayer)
 {
     abilityName = "Stomp";
     tooltipText = "Smash the floor dealing n aoe damage";
     staminaCost = 2;
 }
Exemple #8
0
 public ComboScript(CharacterScript attachedPlayer)
     : base(attachedPlayer)
 {
     abilityName = "Combo";
     tooltipText = "Attack a unit using a combo";
     staminaCost = 3;
 }
 void Start()
 {
     instance = this;
     this.enabled = false;	// The game can enable this script when the game is paused
     GameObject player = GameObject.FindWithTag("Player");
     characterScript = player.GetComponent<CharacterScript>();
     optionsScript = transform.parent.GetComponentInChildren<OptionsScript>();
 }
Exemple #10
0
 public MoveScript(CharacterScript attachedPlayer)
     : base(attachedPlayer)
 {
     abilityName = "Move";
     tooltipText = "Move to the selected tile";
     staminaCost = 2;
     range = 1;
 }
Exemple #11
0
 public Task(string type, CharacterScript actor, CharacterScript actee, Item item, LocaleScript locale)
 {
     this.Type = type;
     this.Actor = actor;
     this.Actee = actee;
     this.Item = item;
     this.Locale = locale;
 }
Exemple #12
0
    void Start()
    {
        cs = this.GetComponent<CharacterScript>();
        ms = this.GetComponent<MovementScript>();

        likes = new ArrayList();
        ts = GameObject.FindGameObjectWithTag("Grid").GetComponent<TileScript>();
    }
Exemple #13
0
    // Use this for initialization
    void Start()
    {
        character = GetComponentInParent<CharacterScript>();
        ownerType = character.gameObject.tag; // Get the character's tag so we can decide who the ability should damage

        UseAbility (character.gameObject);
        Destroy(gameObject, duration);	// Effect will go away after (duration) time)
    }
 public BasicAttackScript(CharacterScript attachedPlayer)
     : base(attachedPlayer)
 {
     abilityName = "Basic Attack";
     tooltipText = "Attack a unit using your basic attack";
     staminaCost = 2;
     damage = 2;
     range = 1;
 }
    void Start()
    {
        character = GetComponentInParent<CharacterScript>();
        ownerType = character.gameObject.tag;	// Get the character's tag so we can decide who the ability should damage

        //projectileCollider = GetComponent<BoxCollider2D>();

        Destroy(gameObject, duration);	// Only lives for 20 seconds to prevent leaks
    }
Exemple #16
0
 public CircleAttack(CharacterScript attachedPlayer)
     : base(attachedPlayer)
 {
     abilityName = "Circle Attack";
     tooltipText = "Attack all enemies around you";
     staminaCost = 4;
     damage = 2;
     range = 1;
 }
Exemple #17
0
 public RockThrowScript(CharacterScript attachedPlayer)
     : base(attachedPlayer)
 {
     abilityName = "Rock Throw";
     tooltipText = "Throw a rock at target character";
     staminaCost = 2;
     damage = 1;
     range = 1;
 }
	// Use this for initialization
	void Start () {

		this.character = GameObject.FindGameObjectWithTag ("Player");
		this.cs = this.character.GetComponent<CharacterScript> ();

		// ADD TEXTURES
		this.DamageFadeTexture = Resources.Load<Texture>("DamageFading/bloodscreen");

	}
Exemple #19
0
	void Start(){

		
		this.character = GameObject.FindGameObjectWithTag ("Player");
		cs = this.character.GetComponent<CharacterScript> ();

		weaponTransform = weapon.transform;
		shieldTransform = shield.transform;
 
	}
Exemple #20
0
	//private GameObject heart;
	
	void Start () {
		// Buscamos al personaje principal
		//this.Player = GameObject.FindGameObjectWithTag("Player");
		this.character = GameObject.FindGameObjectWithTag ("Player");
		//this.heart = GameObject.Find ("heart1");
		//cs = GetComponent<CharacterScript>();
		//cs = GetComponent<CharacterScript>();
		
		cs = GameObject.FindObjectOfType(typeof(CharacterScript)) as CharacterScript;

	}
    // Use this for initialization
    void Start()
    {
        gameManagerScript = GetComponent<GameManagerScript> ();
        characterScript = GameObject.Find ("Character").GetComponent<CharacterScript> ();

        danceBar.value = initialValue;
        currentValue = initialValue;

        danceType = 1;
        tapCount = 0;
    }
Exemple #22
0
 public PushScript(CharacterScript attachedPlayer)
     : base(attachedPlayer)
 {
     abilityName = "Push";
     tooltipText = "Push target character";
     staminaCost = 4;
     damage = 0;
     range = 1;
     //	TODO: Use this -> int pushDistance = 1;
     //TODO: Fix range so that it represents the amount of tile coordinates away instead of float
 }
Exemple #23
0
    void Start()
    {
        characterScript = GetComponent<CharacterScript>();

        // Grab player info
        player = GameObject.FindGameObjectWithTag("Player");

        // Save spawn point in case we need to leash later
        spawnPoint = transform.position;

        // Create stack of commands for AI behavior
        commands = new CommandStackScript();
    }
    // Update is called once per frame
    void Update()
    {
        if(healthBar) {
            // This feels like a hack. If you put it in Start() it doesn't load properly.
            character = healthBar.character;	// Get reference to character the healthbar is attached to
        }

        if(character) {
            guitext.text = character.name;
        }

        //		transform.position = transform.parent.position;
    }
Exemple #25
0
	// Use this for initialization
	void Start () {
		//
		this.fireball = Resources.Load<GameObject>("Prefabs/Character_Skills/Fireball_Skill");
		this.warrior_aura = Resources.Load<GameObject>("Prefabs/Character_Skills/Warrior_Aura1");
		this.dagger_shot = Resources.Load<GameObject>("Prefabs/Character_Skills/Daga_skill/Daga_skill");
		
		this.player = GameObject.FindGameObjectWithTag("Player");
		this.cs = this.player.GetComponent<CharacterScript> ();
		this.cm = this.player.GetComponent<ClickToMove> ();
		this.cm2 = this.player.GetComponent<ClickToMove_lvl2> ();

		effect = false;
		actual_time = Time.time;
	}
Exemple #26
0
    // Use this for initialization
    void Start()
    {
        // Find character by searching parent's character script
        character = transform.parent.GetComponent<CharacterScript>();
        if(character) {
            // Assuming character exists)
            health = character.GetComponent<HealthScript>();

            maxHp = health.hp;	// HP when mob spawns is assumed to be the total hp it can have
        }

        // Find current HP bar
        currentHPBar = transform.GetComponentInChildren<GUITexture>();
        currentHPBar.transform.localScale = Vector3.zero;	// Zero-out the scale vector to allow us to manipulate it later
    }
Exemple #27
0
    //Parse Top Card of Queue
    void ParseCards()
    {
        CharacterScript character = player.GetComponent <CharacterScript>();

        if (character.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("idle"))
        {
            character.parseCard();
        }
        //if (queueIndex < queuedCards.Length)
        //    Queue.GetComponent<Text>().text = queuedCards[queueIndex].GetComponent<CardButtonScript>().card.GetComponent<CardScript>().cardName;
        //else
        //    Queue.GetComponent<Text>().text = "";

        //RemoveNonBasics();
    }
Exemple #28
0
    private void SetUpAgentAndAnim()
    {
        agent       = gameObject.AddComponent <NavMeshAgent>();
        agent.speed = npcSpeed;
        anim        = GetComponent <SoliderAnimScript>();
        anim.setNpc(agent);
        character = GetComponent <CharacterScript>();
        team      = GetComponent <TeamSide>();
        health    = GetComponent <HealthScript>();

        if (!agent)
        {
            Debug.Log("No NavMeshAgent attached to this npc");
        }
    }
    private void SelectTarget()
    {
        //Debug.Log("Mouse 0 is down");
        RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

        if (hit.collider != null && hit.collider.transform.CompareTag("BattleParticipant"))
        {//If target has a collider and is a battle participant, note that battle participants MUST have a CharacterScript.
            selectedTargetToAttack = hit.collider.gameObject.GetComponent <CharacterScript>();
            Debug.Log("Selected target: " + selectedTargetToAttack.characterName);
        }
        else
        {
            Debug.Log("No hit/target found");
        }
    }
Exemple #30
0
    public IEnumerator ShieldDash(CharacterScript target, float moveTime)
    {
        Vector3 oldPos = transform.position;

        StartCoroutine(MoveTo(target.transform.position, moveTime / 2));
        yield return(new WaitForSeconds(moveTime / 2));

        target.ProtectionIncrease(0.5f);
        ReduceMana(manaCost);
        StartCoroutine(MoveTo(oldPos, moveTime / 2));
        yield return(new WaitForSeconds(moveTime / 2));

        transform.position = oldPos;
        yield return(null);
    }
Exemple #31
0
 // Update is called once per frame
 void Update()
 {
     if (levelTime > 0)
     {
         levelTime -= Time.deltaTime;
         timerDisplay.GetComponent <Text>().text = "Timer: " + FormatTime(levelTime);
     }
     else
     {
         levelTime = 0;
         timerDisplay.GetComponent <Text>().text = "Timer: " + FormatTime(levelTime);
         SceneManager.LoadScene("LoseScene");
         CharacterScript.FindObjectOfType <CharacterScript>().enabled = false;
     }
 }
Exemple #32
0
    public IEnumerator HealDash(CharacterScript target, float moveTime)
    {
        Vector3 oldPos = transform.position;

        StartCoroutine(MoveTo(target.transform.position, moveTime / 2));
        yield return(new WaitForSeconds(moveTime / 2));

        target.Healed(healstrength);
        ReduceMana(manaCost);
        StartCoroutine(MoveTo(oldPos, moveTime / 2));
        yield return(new WaitForSeconds(moveTime / 2));

        transform.position = oldPos;
        yield return(null);
    }
    // Use this for initialization
    void Start()
    {
        characterScript = character.GetComponent <CharacterScript>();
        showText        = timerText.GetComponent <Text>();
        int currentStage = SceneManager.GetActiveScene().buildIndex;

        if (currentStage == 3)
        {
            countdown = 600f;
        }
        else if (currentStage == 4)
        {
            countdown = 1200f;
        }
    }
Exemple #34
0
    public void Refresh()
    {
        int armyCount;
        int i = armyStateList.transform.childCount;

        if (CS_TurnOverPanel.turn == FinalVar.RED)
        {
            armyCount = CS_ArmyManager.GetRedCount();
        }
        else
        {
            armyCount = CS_ArmyManager.GetBlueCount();
        }
        while (i > armyCount)
        {
            Destroy(armyStateList.transform.GetChild(--i).gameObject);
        }
        while (i < armyCount)
        {
            GameObject go      = Resources.Load("PreArmy") as GameObject;
            GameObject preArmy = Instantiate(go) as GameObject;
            preArmy.transform.SetParent(armyStateList.transform, false);
            preArmy.GetComponent <RectTransform>().sizeDelta = new Vector2(Screen.width, preArmy.GetComponent <RectTransform>().rect.height);
            preArmy.transform.position = armyStateList.transform.position;
            preArmy.transform.Translate(Vector3.down * i++ *preArmy.GetComponent <RectTransform>().rect.height);
        }
        while (i > 0)
        {
            i--;
            CharacterScript cs = CS_ArmyManager.GetCharacter(i);
            armyStateList.transform.GetChild(i).GetComponent <CS_PreArmy>().characterScript       = cs;
            armyStateList.transform.GetChild(i).transform.GetChild(1).GetComponent <Text>().text  = cs.charactorName;
            armyStateList.transform.GetChild(i).transform.GetChild(3).GetComponent <Text>().text  = i.ToString();
            armyStateList.transform.GetChild(i).transform.GetChild(5).GetComponent <Text>().text  = cs.hp.ToString();
            armyStateList.transform.GetChild(i).transform.GetChild(7).GetComponent <Text>().text  = cs.mp.ToString();
            armyStateList.transform.GetChild(i).transform.GetChild(9).GetComponent <Text>().text  = cs.ap.ToString();
            armyStateList.transform.GetChild(i).transform.GetChild(11).GetComponent <Text>().text = cs.dp.ToString();
            armyStateList.transform.GetChild(i).transform.GetChild(13).GetComponent <Text>().text = cs.lv.ToString();
            if (cs.moved)
            {
                armyStateList.transform.GetChild(i).transform.GetChild(14).GetComponent <Text>().text = "移动后";
            }
            else
            {
                armyStateList.transform.GetChild(i).transform.GetChild(14).GetComponent <Text>().text = "移动前";
            }
        }
    }
    /*
     * public void moveToFront(int mover)
     * {
     *  if (mover == 1)
     *  {
     *      if (charPos[2].getAlive())                // 3 2 1 F -> 1 3 2 F
     *      {
     *          CharacterScript temp1 = charPos[0];
     *          CharacterScript temp2 = charPos[2];
     *
     *          charPos[0] = charPos[mover];
     *          charPos[1] = temp2;
     *          charPos[2] = temp1;
     *      }
     *      else                                     // x 2 1 F -> x 1 2 F
     *      {
     *          CharacterScript temp = charPos[0];
     *
     *          charPos[0] = charPos[mover];
     *          charPos[1] = temp;
     *      }
     *
     *  }
     *  else if (mover == 2)      // 3 2 1 F -> 1 2 3 F
     *  {
     *      CharacterScript temp = charPos[0];
     *
     *      charPos[0] = charPos[mover];
     *      charPos[2] = temp;
     *  }
     * }
     *
     * public void moveToMiddle(int mover)
     * {
     *  if (!charPos[1].getReady() && mover == 2)           // 3 2 1 F -> 2 3 1 F
     *  {
     *      CharacterScript temp = charPos[1];
     *
     *      charPos[1] = charPos[2];
     *      charPos[2] = temp;
     *  }
     * }
     *
     * public void moveToBack(int mover)
     * {
     *  if (mover == 0)
     *  {
     *      CharacterScript temp = charPos[0];
     *
     *      charPos[0] = charPos[1];
     *      charPos[1] = charPos[2];
     *      charPos[2] = temp;
     *  }
     *  else if (mover == 1)
     *  {
     *      CharacterScript temp = charPos[1];
     *
     *      charPos[1] = charPos[2];
     *      charPos[2] = temp;
     *  }
     * }
     */
    /*
     * public void swap()
     * {
     *  if (charPos[2].getAlive())
     *  {
     *      charPos[2].actionBar += 20.0f;
     *      moveToFront(2);
     *  }
     *  else if (charPos[1].getAlive())
     *  {
     *      charPos[1].actionBar += 20.0f;
     *      moveToFront(1);
     *  }
     *  else
     *  {
     *      charPos[0].actionBar += 100.0f;
     *  }
     * }
     */
    /*
     * public void updatePos()
     * {
     *  if (!charPos[0].getReady())
     *      if (charPos[1].getReady())
     *          moveToFront(1);
     *      else if (charPos[2].getReady())
     *          moveToFront(2);
     *
     *  if (charPos[0].getReady() && !charPos[1].getReady())
     *      if (charPos[2].getReady())
     *          moveToMiddle(2);
     *
     *  charPos[0].targetPos = new Vector2(x1, 0);
     *  charPos[0].pos = 0;
     *  charPos[1].targetPos = new Vector2(x2, 0);
     *  charPos[1].pos = 1;
     *  charPos[2].targetPos = new Vector2(x3, 0);
     *  charPos[2].pos = 2;
     * }
     */

    new public IEnumerator basicAttack()
    {
        CharacterScript attacker = charPos[0].GetComponent <CharacterScript>();

        takingAction = true;

        yield return(new WaitForSeconds(delay));

        if (attacker == charPos[0].GetComponent <CharacterScript>() && charPos[0].ready)
        {
            charPos[0].actionBar = 0.0f;
            enemyTeam.applyDamage(charPos[0].attack, charPos[0].basicAttackType, 0);
        }

        takingAction = false;
    }
    private void Start()
    {
        characterScript = GetComponent <CharacterScript>();
        stats           = GetComponent <Stats>();
        portraitScript  = GetComponent <PortraitScript>();
        role            = characterScript.role;

        if (role != null)
        {
            portraitScript.Background.GetComponent <Image>().sprite = role.portraitBackground;
        }
        else
        {
            portraitScript.NoRole();
        }
    }
Exemple #37
0
    void InstantiateCharacter()
    {
        if (playerCharacter != null)
        {
            return;
        }

        var player = Instantiate(playerCharacterPrefab, transform.position, transform.rotation, transform);

        playerCharacter = player.GetComponent <CharacterScript>();
        playerCharacter.winAnnouncement = UIManager.instance.announcement;
        playerCharacter.winAnnouncement.gameObject.SetActive(false);
        playerCharacter.coinCounter     = UIManager.instance.coinCounter;
        InputManager.instance.character = playerCharacter;
        CameraManager.instance.target   = playerCharacter.transform;
    }
    public void GachaCharacter()
    {
        if (PlayerScript.Instance().characterList.Count.Equals(PlayerScript.Instance().GetMaxCharacter()))
        {
            messageText.text = "Character window is filled!!";
        }
        else
        {
            CharacterScript temp = Instantiate(characterManager.characters[Random.Range(0, characterManager.characters.Count)],
                                               new Vector3(0, 0, 0), Quaternion.identity);
            temp.gameObject.transform.SetParent(PlayerScript.Instance().gameObject.transform);
            PlayerScript.Instance().characterList.Add(temp);

            DisplayCharacterList();
        }
    }
    // Type out the sentence letter by letter and make character idle if they were talking
    IEnumerator TypeSentence(string sentence)
    {
        message.text = "";
        foreach (char letter in sentence.ToCharArray())
        {
            message.text += letter;
            yield return(null);
        }
        CharacterScript tempSpeaker = GameObject.FindObjectOfType <CharacterScript>();

        if (tempSpeaker.isTalking)
        {
            SetAnimation("idle");
        }
        yield return(null);
    }
Exemple #40
0
 // Start is called before the first frame update
 void Start()
 {
     BombTypePanel   = GameObject.Find("Canvas/ControlsPanel/BomberPanel/BombTypePanel").GetComponent <CanvasGroup>();
     buttonControl   = GameObject.Find("Canvas/ControlsPanel/BomberPanel/PlantButton").GetComponent <WalkButtonControl>();
     landMineButton  = GameObject.Find("Canvas/ControlsPanel/BomberPanel/BombTypePanel/MineButton").GetComponent <Button>();
     timerBombButton = GameObject.Find("Canvas/ControlsPanel/BomberPanel/BombTypePanel/TimerButton").GetComponent <Button>();
     closeButton     = GameObject.Find("Canvas/ControlsPanel/BomberPanel/BombTypePanel/CloseButton").GetComponent <Button>();
     PlayPanel       = GameObject.Find("Canvas/ControlsPanel/PlayPanel").GetComponent <CanvasGroup>();
     bombPrefab      = Resources.Load <GameObject>("Bomb");
     animator        = GetComponent <Animator>();
     trigger         = true;
     tempScript      = gameObject.GetComponent <CharacterScript>();
     landMineButton.onClick.AddListener(delegate { plantBomb(0); });
     timerBombButton.onClick.AddListener(delegate { plantBomb(1); });
     closeButton.onClick.AddListener(delegate { closeButtonAction(); });
 }
Exemple #41
0
    public void CharacterInfo(GameObject character)
    {
        CharacterScript characterScript = character.GetComponent <CharacterScript>();
        Stats           stats           = character.GetComponent <Stats>();

        txtRoleName.text = characterScript.strName;
        txtRoleDesc.text = "";
        txtHp.text       = "Hp: " + stats.hp;
        txtStr.text      = "Str: " + stats.str;
        txtDef.text      = "Def: " + stats.def;
        txtDex.text      = "Dex: " + stats.dex;
        txtInt.text      = "Int: " + stats.Int;
        txtLdr.text      = "Ldr: " + stats.ldr;
        txtSnt.text      = "Snt: " + stats.snt;
        txtCha.text      = "Cha: " + stats.cha;
    }
Exemple #42
0
    // OnDefend
    public void Retaliate(CharacterScript char1, CharacterScript char2, Attack atk, Item weapon, StatusEffect effect)
    {
        int finalDamage = 0;

        if (char1.weaponR != null)
        {
            if (!char1.weaponR.attacksList[0].magical)
            {
                finalDamage += (int)((float)char1.weaponR.Health * char1.weaponR.attacksList[0].damageModifier / 100f * char1.strength / char2.resistance);
            }
            else
            {
                finalDamage += (int)((float)char1.weaponR.Magic * char1.weaponR.attacksList[0].damageModifier / 100f * char1.intelligence / char2.spirit);
            }
        }

        if (char1.weaponL != null)
        {
            if (!char1.weaponL.attacksList[0].magical)
            {
                finalDamage += (int)((float)char1.weaponL.Health * char1.weaponL.attacksList[0].damageModifier / 100f * char1.strength / char2.resistance);
            }
            else
            {
                finalDamage += (int)((float)char1.weaponL.Magic * char1.weaponL.attacksList[0].damageModifier / 100f * char1.intelligence / char2.spirit);
            }
        }

        if (char1.weaponR == null && char1.weaponL == null)
        {
            if (!InventoryScript.Instance.defaultWeapon.attacksList[0].magical)
            {
                finalDamage += (int)((float)InventoryScript.Instance.defaultWeapon.Health * InventoryScript.Instance.defaultWeapon.attacksList[0].damageModifier / 100f * char1.strength / char2.resistance);
            }
            else
            {
                finalDamage += (int)((float)InventoryScript.Instance.defaultWeapon.Magic * InventoryScript.Instance.defaultWeapon.attacksList[0].damageModifier / 100f * char1.intelligence / char2.spirit);
            }
        }

        if (UnityEngine.Random.Range(1, 100) >= 100 - effect.statusPower + char1.luck - char2.speed)
        {
            battleController.DisplayText(char1.gameObject.name + "is counter-attacking!");
            char2.ModifyHealth(finalDamage);
            totalDamage += finalDamage;
        }
    }
    private void CreateCharacterWindow()
    {
        characterWindowPos = new Vector3(-162.5f / contreverter, 300 / contreverter, 0);

        foreach (GameObject character in characters)   //Kan någon kolla varför de skrivs ut på ett så konstigt ställe?
        {
            characterScript  = character.GetComponent <CharacterScript>();
            characterWindowO = Instantiate(characterWindow);
            characterWindowO.transform.parent = GameObject.Find("CharacterWindowManager").transform;
            characterWindowO.GetComponent <CharacterWindow>().GetInfo(characterScript.strName, characterScript.id); //Vad används denna till?
            characterWindowO.transform.localScale = new Vector3(1, 1, 1);
            characterWindowO.transform.position   = characterWindowPos;
            characterWindowPos.y -= 100 / contreverter;

            //Implementera en scroll funktion om man har fler än x antal karaktärer?
        }
    }
        /// <summary>
        /// Creates a new instance of parameter scriptType as a Script object
        /// </summary>
        /// <param name="scriptType">The type of the script to be instantialized</param>
        /// <param name="scriptName">The name of the script</param>
        /// <param name="chr">The character that triggered the creation of the script</param>
        /// <returns>The created Script instance</returns>
        public static Script CreateScriptInstance(Type scriptType, string scriptName, MapleCharacter chr)
        {
            var instance = Activator.CreateInstance(scriptType) as Script;

            if (instance == null)
            {
                ServerConsole.Error(string.Format("Type {0} cannot be cast to 'Script'", scriptType));
                return(null);
            }
            if (instance is CharacterScript)
            {
                CharacterScript cInstance = (CharacterScript)instance;
                cInstance.Character = new ScriptCharacter(chr, scriptName);
            }
            instance.DataProvider = ScriptDataProvider;
            return(instance);
        }
    void Start()
    {
        help = FindObjectOfType <HelpController> ();
        rt   = root.GetComponent <RectTransform> ();
        UnityEngine.UI.CanvasScaler cnv = rt.root.GetComponent <UnityEngine.UI.CanvasScaler> ();
        float canvasRatio = Mathf.Lerp(cnv.referenceResolution.x, cnv.referenceResolution.y, cnv.matchWidthOrHeight);
        float screenRatio = Mathf.Lerp(Screen.width, Screen.height, cnv.matchWidthOrHeight);

        scaleRatio = canvasRatio / screenRatio;

        character = target.GetComponent <CharacterScript>();

        if (root)
        {
            root.SetActive(false);
        }
    }
Exemple #46
0
    // Update is called once per frame
    void Update()
    {
        CharacterScript tempScript = gameObject.GetComponent <CharacterScript>();

        if (buttonControl.pressed && trigger && tempScript.ammo > 0)
        {
            trigger = false;
            animator.SetTrigger("shoot");
            tempScript.ammo = tempScript.ammo - 1;
            StartCoroutine(BulletDrop());
        }

        if (!buttonControl.pressed)
        {
            trigger = true;
        }
    }
Exemple #47
0
	// Use this for initialization
	void Start () {

		this.character = GameObject.FindGameObjectWithTag ("Player");
		this.cs = this.character.GetComponent<CharacterScript> ();
		
		this.max_health = this.cs.getMaxHealth ();
		this.VIT = this.max_health;
		this.max_magic = this.cs.getMaxMagic ();
		this.PM = this.max_magic;

		// Resize the health and magic bar with the actual values
		this.resize_health = this.scale * Mathf.Pow(this.cs.getHealth() / this.cs.getMaxHealth (), -1);
		this.resize_magic = this.scale * Mathf.Pow(this.cs.getMagic() / this.cs.getMaxMagic (), -1);

		// Set the news actual max life and magic
		this.cs.setMaxHealth ();
		this.cs.setMaxMagic ();
		//this.max_health = this.bar_health;
		//this.max_magic = this.bar_magic;

		// ADD TEXTURES
		this.AvatarTexture = Resources.Load<Texture2D>("HealthBar/avatar_" + PlayerPrefs.GetString("Player"));
		this.HealthTexture = Resources.Load<Texture2D>("HealthBar/health");
		this.HealthBarTexture = Resources.Load<Texture2D>("HealthBar/bar_health");
		this.DamageBarTexture = Resources.Load<Texture2D>("HealthBar/damage_health");
		this.MagicTexture = Resources.Load<Texture2D>("HealthBar/magic");
		this.MagicBarTexture = Resources.Load<Texture2D>("HealthBar/bar_magic");
		this.LowMagicTexture = Resources.Load<Texture2D>("HealthBar/caution");
		this.DecotrationTextureUp = Resources.Load<Texture2D>("HealthBar/decoracion_up");
		this.DecotrationTextureDown = Resources.Load<Texture2D>("HealthBar/decoracion_down");

		// ADD MATERIALS
		this.HealthBarMaterial = Resources.Load<Material>("HealthBar/Materials/bar_health");
		this.DamageBarMaterial = Resources.Load<Material>("HealthBar/Materials/damage_health");
		this.MagicBarMaterial = Resources.Load<Material>("HealthBar/Materials/bar_magic");

		this.health = 0f;
		this.HealthBarMaterial.SetFloat("_Cutoff", this.health);

		this.damage = 0f;
		this.DamageBarMaterial.SetFloat("_Cutoff", this.damage);

		this.magic = 0f;
		this.MagicBarMaterial.SetFloat("_Cutoff", this.magic);
	
	}
Exemple #48
0
    // Async method for teleport
    private IEnumerator SetCharacterPositionAsync(CharacterScript character, Cell cell, SetCharacterPositionCallBack callback)
    {
        Entity entity = character.transform.GetComponent(typeof(Entity)) as Entity;

        IsoUnity.Cell destinyCell = SearchCellInMap(cell);
        var           setCharacterPositionEvent = new GameEvent("teleport", new Dictionary <string, object>()
        {
            { "mover", entity.mover },
            { "cell", destinyCell },
            { "synchronous", true }
        });

        Game.main.enqueueEvent(setCharacterPositionEvent);
        yield return(new WaitForEventFinished(setCharacterPositionEvent));

        callback(true);
    }
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "PlayerFlagger")
     {
         flagColor.color       = CharacterScript.SetColor(ruleAndUi.colorForPlayer);
         this.gameObject.layer = 13;
         Destroy(GameObject.Find(collision.gameObject.name));
         Owner = "Player";
     }
     else if (collision.gameObject.tag == "EnemyFlagger")
     {
         flagColor.color       = CharacterScript.SetColor(ruleAndUi.colorForEnemy);;
         this.gameObject.layer = 12;
         Destroy(GameObject.Find(collision.gameObject.name));
         Owner = "Enemy";
     }
 }
    void Start()
    {
        // Set up code. This populates your characters with their controlling scripts
        character1 = transform.Find("Character1").gameObject.GetComponent <CharacterScript>();
        character2 = transform.Find("Character2").gameObject.GetComponent <CharacterScript>();
        character3 = transform.Find("Character3").gameObject.GetComponent <CharacterScript>();

        // populate the objectives
        middleObjective = GameObject.Find("MiddleObjective").GetComponent <ObjectiveScript>();
        leftObjective   = GameObject.Find("LeftObjective").GetComponent <ObjectiveScript>();
        rightObjective  = GameObject.Find("RightObjective").GetComponent <ObjectiveScript>();

        // save our team, changes every time
        ourTeamColor = character1.getTeam();
        //Makes gametimer call every second
        InvokeRepeating("gameTimer", 0.0f, 1.0f);
    }
Exemple #51
0
 public void InventoryGetPlayerValues()
 {
     playerScript = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterScript>();
     if (playerScript != null)
     {
         health    = playerScript.health;
         maxHealth = playerScript.maxHealth;
         attack    = playerScript.damage;
         speed     = playerScript.speed;
         defence   = playerScript.defence;
         Debug.Log("PAYER -> INVENTORY");
     }
     else
     {
         Debug.Log("PLAYERSCRIPT == NULL");
     }
 }
Exemple #52
0
    protected void CheckAttack(Vector3 i_TargetPosition)
    {
        if (Vector3.Distance(i_TargetPosition, transform.position) <= m_AttackRange)
        {
            RaycastHit2D[] hits = Physics2D.RaycastAll(i_TargetPosition, Vector3.zero, 1);

            foreach (RaycastHit2D hit in hits)
            {
                CharacterScript charScript = hit.transform.GetComponent <CharacterScript>();
                if (hit.transform != transform && charScript)
                {
                    charScript.CmdDamageCharacter(m_AttackPower);
                    break;
                }
            }
        }
    }
Exemple #53
0
    public void AddDefender(CharacterScript char1, CharacterScript char2, StatusEffect effect)
    {
        switch (effect.statusMiscText.ToLower())
        {
        default:
        case "defend":
        case "cover":

            char1.defender = char2.gameObject;
            break;

        case "reflect":

            char1.reflect = true;
            break;
        }
    }
Exemple #54
0
    private void OnTriggerEnter(Collider other)
    {
        CharacterScript sdt = other.gameObject.GetComponent <CharacterScript>();

        if (owner.attacking)
        {
            if (sdt != null && sdt != owner)
            {
                sdt.hurt(damage);
            }
        }
        if (owner.attacking && other.gameObject.tag == "Ball")
        {
            ballrigid.AddForce(forceamount, ForceMode.Impulse);
            Debug.Log("ball was hit");
        }
    }
Exemple #55
0
    // Async method for show area
    private IEnumerator ShowAreaAsync(CharacterScript character, EventTypes eventType, Skills skill, ShowAreaCallBack callback)
    {
        Entity entity = character.transform.GetComponent(typeof(Entity)) as Entity;

        IsoUnity.Cell characterCurrentCell = character.transform.parent.transform.GetComponent(typeof(IsoUnity.Cell)) as IsoUnity.Cell;
        try
        {
            entity.mover.maxJumpSize = character.character.attributesWithFormulas.Find(x => x.attribute.id == moveHeight.id).value;
        }
        catch (NullReferenceException e)
        {
            Debug.Log("Character '" + character.character.name + "' doesn't have attribute '" + moveHeight.name + "'");
        }

        selectedCellEvent = new GameEvent("selected cell", new Dictionary <string, object>()
        {
            { "synchronous", true }
        });

        Game.main.enqueueEvent(selectedCellEvent);
        try
        {
            if (eventType == EventTypes.MOVE)
            {
                CalculateDistanceArea(entity, characterCurrentCell, eventType, character.character.attributesWithFormulas.Find(x => x.attribute.id == moveRange.id).value, character.character.attributesWithFormulas.Find(x => x.attribute.id == moveHeight.id).value);
            }
            else if (eventType == EventTypes.ATTACK)
            {
                CalculateDistanceArea(entity, characterCurrentCell, eventType, character.character.attributesWithFormulas.Find(x => x.attribute.id == attackRange.id).value, character.character.attributesWithFormulas.Find(x => x.attribute.id == attackHeight.id).value);
            }
        }
        catch (NullReferenceException e)
        {
            Debug.Log(e);
        }

        Dictionary <string, object> outParams;

        yield return(new WaitForEventFinished(selectedCellEvent, out outParams));

        cleanCells();
        IsoUnity.Cell selectedCell = outParams["cell"] as IsoUnity.Cell;
        Cell          returnCell   = new Cell((int)selectedCell.Map.getCoords(selectedCell.gameObject).x, (int)selectedCell.Map.getCoords(selectedCell.gameObject).y);

        callback(returnCell, true);
    }
Exemple #56
0
    private void Start()
    {
        stats           = GetComponent <Stats>();
        characterScript = GetComponent <CharacterScript>();

        startWeaponList = new List <WeaponObject>();
        startCloth      = new List <ClothItemObject>();
        startHeadGear   = new List <ClothItemObject>();

        CreateStats();
        CreateName();
        CreateBirth();
        CreateStory();
        GetEquipment();

        characterScript.NewCharacter(fullName, cloth.name, headGear.name);
    }
Exemple #57
0
    public void Hospital()
    {
        characterArr = GameObject.FindGameObjectsWithTag("Character");
        foreach (GameObject character in characterArr)
        {
            CharacterScript characterScript = character.GetComponent <CharacterScript>();
            if (characterScript.inHospital)
            {
                Stats stats = character.GetComponent <Stats>();

                bool isWounded = true;

                while (isWounded)
                {
                    isWounded = false;

                    for (int i = 0; i < stats.quirkList.Count; i++)
                    {
                        if (stats.quirkList[i].quirkType == QuirkScript.QuirkType.woundQuirk)
                        {
                            if (stats.quirkList[i].quirkLevel <= hospitalLevel + 1)
                            {
                                stats.RemoveQuirk(stats.quirkList[i]);
                                isWounded = true;
                            }
                        }
                    }
                }



                //foreach (QuirkObject quirk in stats.quirkList) {
                //    if (quirk.quirkType == QuirkScript.QuirkType.woundQuirk) {
                //        if (quirk.quirkLevel <= hospitalLevel + 1) {
                //            stats.RemoveQuirk(quirk);
                //            break;
                //        }
                //    }
                //}

                stats.hp = stats.maxHp;
                characterScript.inHospital = false;
            }
        }
    }
Exemple #58
0
    public void initializeCharacter()
    {
        cs = this.GetComponent<CharacterScript>();
        pcp = this.GetComponent<PassiveMoverCharacters>();

        if(cs.type == CharacterScript.Element.Wind){
            transitionTiming = 2.0f;
        }
        if(cs.type == CharacterScript.Element.Water){
            transitionTiming = 2.1f;
        }
        if(cs.type == CharacterScript.Element.Earth){
            transitionTiming = 0.8f;
        }
        if(cs.type == CharacterScript.Element.Fire){
            transitionTiming = 1.0f;
        }
    }
	// Use this for initialization
	void Start () {
		this.game_engine = GameObject.FindGameObjectWithTag ("GameController");
		this.health_bar = this.gameObject.GetComponent<NPCHealthBar_lvl2> ();
		this.game_script = game_engine.GetComponent <GameEngineLevel02_new> ();
		this.player = GameObject.FindGameObjectWithTag("Player");
		this.music = GameObject.FindGameObjectWithTag ("music_engine").GetComponent<Music_Engine_Script> ();
		this.player_transform = player.transform;
		this.player_script = player.GetComponent<CharacterScript> ();
		this.skill = Resources.Load<GameObject> ("Prefabs/Boss_Skills/Boss_skill_2");

		this.respawn = transform.position;
		this.health_bar.enabled = false;

		setAtrributesDifficulty (PlayerPrefs.GetString ("Difficult"));

		state = 0;
		Anim.animation.CrossFade (IdleAnimation.name, 0.12f);
	}
Exemple #60
0
	// Use this for initialization
	void Start () {

		this.character = GameObject.FindGameObjectWithTag ("Player");
		this.cs = this.character.GetComponent<CharacterScript> ();
		this.cm = this.character.GetComponent<ClickToMove> ();
		//this.cm2 = this.character.GetComponent<ClickToMove_lvl2> ();

		// ADD TEXTURES
		this.actionBarTexture = Resources.Load<Texture2D>("ActionBar/actionbar");

		this.fireballTexture = Resources.Load<Texture2D>("ActionBar/skill_fireball");
		this.reloadFireballTexture = Resources.Load<Texture2D>("ActionBar/reload_fireball");
		this.PowerKnifeTexture = Resources.Load<Texture2D>("ActionBar/skill_powerKnife");
		this.reloadPowerKnifeTexture = Resources.Load<Texture2D>("ActionBar/reload_powerKnife");
		this.DarkAuraTexture = Resources.Load<Texture2D>("ActionBar/skill_aura");
		this.reloadDarkAuraTexture = Resources.Load<Texture2D>("ActionBar/reload_aura");

		this.attackIconTexture = Resources.Load<Texture2D>("ActionBar/icon_attack_v2");
		this.runIconTexture = Resources.Load<Texture2D>("ActionBar/icon_run");
		this.potionIconTexture = Resources.Load<Texture2D>("ActionBar/icon_elixir_v2");
		this.inventoryIconTexture = Resources.Load<Texture2D>("ActionBar/icon_inventory_v2");
		this.mapIconTexture = Resources.Load<Texture2D>("ActionBar/icon_map");

		//Debug.Log (this.actionBarTexture.name);

		inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent<InventoryScript> ();

		//this.cs = GameObject.FindGameObjectWithTag ("Player").GetComponent<CharacterScript> ();

		this.text_style = new GUIStyle ();
		this.text_style.normal.textColor = Color.red;
		this.text_style.fontSize = 15;
		this.text_style.alignment = TextAnchor.UpperCenter ; 
		this.text_style.wordWrap = true; 

		disabledSkill1 = false;
		disabledSkill2 = false;
		disabledSkill3 = false;


	}