Exemplo n.º 1
0
    public void ChangeWeapon(WeaponController newWeapon)
    {
        if (current_Weapon)
        {
            Destroy(current_Weapon.gameObject);
        }


        current_Weapon    = newWeapon;
        currentTypeAttack = newWeapon.defaultConfig.typeAttack;

        current_Weapon = Instantiate(newWeapon, spawnPoint.position, spawnPoint.rotation, spawnPoint);


        shot = newWeapon.GetComponentInChildren <BaseShot>();
        weapons_Unlocked.Insert(0, newWeapon);

        if (weapons_Unlocked.Count > maxSlotWeapon)
        {
            Instantiate(weapons_Unlocked[1].weaponPickup, transform.position, Quaternion.identity);
            weapons_Unlocked.RemoveAt(1);
        }
        UIController.Instance.currentGun.sprite = weapons_Unlocked[0].gunUI;
        UIController.Instance.gunText.text      = weapons_Unlocked[0].gunName;
    }
Exemplo n.º 2
0
    private TypeStateCharacter AttackToState(TypeAttack typeAttack)
    {
        switch (typeAttack)
        {
        case TypeAttack.Attack: return(TypeStateCharacter.Attack);

        case TypeAttack.SpecialAttack1: return(TypeStateCharacter.SpecialAttack1Start);

        case TypeAttack.SpecialAttack2: return(TypeStateCharacter.SpecialAttack2);

        default: return(TypeStateCharacter.Attack);
        }
    }
Exemplo n.º 3
0
    private void CmdAttack(float damage, TypeAttack atk, bool spear)
    {
        SyncChunk actual_chunk = null;
        foreach (Collider col in Physics.OverlapBox(this.character.transform.position, new Vector3(5, 100, 5)))
            if (col.gameObject.name.Contains("Island"))
            {
                actual_chunk = col.transform.parent.GetComponent<SyncChunk>();
                break;
            }

        if (actual_chunk != null && actual_chunk.IsCristal && actual_chunk.Cristal.Team == this.social.Team)
            damage += actual_chunk.Cristal.LevelAtk;

        Collider[] cibles = null;
        if (atk == TypeAttack.Horizontal)
            cibles = Physics.OverlapBox(this.character.transform.position - this.character.transform.forward / 2 + new Vector3(0, 0.5f), (spear ? 2 : 1) * new Vector3(0.5f, 0.1f, 0.25f), this.character.transform.rotation);
        else if (atk == TypeAttack.Vertical)
            cibles = Physics.OverlapBox(this.character.transform.position - this.character.transform.forward / 2 + new Vector3(0, 0.5f), (spear ? 2 : 1) * new Vector3(0.2f, 0.5f, 0.25f), this.character.transform.rotation);
        else if (atk == TypeAttack.Aerial)
        {
            cibles = Physics.OverlapBox(this.character.transform.position - this.character.transform.forward / 2 + new Vector3(0, -2f), (spear ? 2 : 1) * new Vector3(0.2f, 2f, 0.25f), this.character.transform.rotation);
            this.syncCharacter.RpcApplyForce(0, -30000f, 0);
        }
        else if (atk == TypeAttack.Charge)
        {
            cibles = Physics.OverlapBox(this.character.transform.position - this.character.transform.forward / 2 + new Vector3(0, 0.5f, 1.5f), new Vector3(0.2f, 0.2f, 1.75f), this.character.transform.rotation);
            this.syncCharacter.RpcApplyRelativeForce(0, 0, -25000f);
        }
        foreach (Collider cible in cibles)
        {
            bool notacible = false;
            if (cible.gameObject.name == "Character" && cible.gameObject.GetComponentInParent<Social_HUD>().Team != this.social.Team)
                cible.gameObject.GetComponentInParent<SyncCharacter>().ReceiveDamage(damage, -(damage / 10f) * this.character.transform.forward, true);
            else if (cible.gameObject.tag == "Mob")
                cible.gameObject.GetComponentInParent<SyncMob>().ReceiveDamage(damage, -(damage / 10f) * this.character.transform.forward);
            else if (cible.gameObject.name.Contains("Islandcore"))
                cible.gameObject.GetComponent<SyncCore>().AttackCristal((int)damage, this.social.Team);
            else if (cible.gameObject.tag == "Boss")
                cible.gameObject.GetComponentInParent<SyncBoss>().ReceiveDamage((int)damage);
            else
                notacible = true;
            if (!notacible && atk == TypeAttack.Horizontal)
                break;
        }
    }
Exemplo n.º 4
0
    public void SwitchWeapon()
    {
        if (weapons_Unlocked.Count > 1)
        {
            if (current_Weapon)
            {
                Destroy(current_Weapon.gameObject);
            }
            var wp = weapons_Unlocked[1];
            weapons_Unlocked[1] = weapons_Unlocked[0];
            weapons_Unlocked[0] = wp;
            current_Weapon      = weapons_Unlocked[0];
            currentTypeAttack   = weapons_Unlocked[0].defaultConfig.typeAttack;
            current_Weapon      = Instantiate(weapons_Unlocked[0], spawnPoint.position, spawnPoint.rotation, spawnPoint);
            shot = weapons_Unlocked[0].GetComponentInChildren <BaseShot>();

            UIController.Instance.currentGun.sprite = weapons_Unlocked[0].gunUI;
            UIController.Instance.gunText.text      = weapons_Unlocked[0].gunName;
        }
    }
Exemplo n.º 5
0
 public Volador(string nombre) : base(nombre)
 {
     this.Tipo  = tipo;
     Attacks[0] = new TypeAttack("Bofeton lodo", 20);
     Attacks[1] = new TypeAttack("Picotazo", 35);
 }
Exemplo n.º 6
0
 public Electrico(string nombre) : base(nombre)
 {
     this.Tipo  = tipo;
     Attacks[0] = new TypeAttack("Impactrueno", 38);
     Attacks[1] = new TypeAttack("Rayo", 50);
 }
Exemplo n.º 7
0
 public Tierra(string nombre) : base(nombre)
 {
     this.Tipo  = tipo;
     Attacks[0] = new TypeAttack("Excavar", 65);
     Attacks[1] = new TypeAttack("Bofeton lodo", 20);
 }
Exemplo n.º 8
0
 public Agua(string nombre) : base(nombre)
 {
     this.Tipo  = tipo;
     Attacks[0] = new TypeAttack("Chorro de agua", 38);
     Attacks[1] = new TypeAttack("Inundacion", 60);
 }
Exemplo n.º 9
0
 public Fuego(string nombre) : base(nombre)
 {
     this.Tipo  = tipo;
     Attacks[0] = new TypeAttack("Ascuas", 40);
     Attacks[1] = new TypeAttack("Calcinacion", 60);
 }
Exemplo n.º 10
0
 public Damage(float _damageSize, TypeAttack _typeAttack)
 {
     this.damageSize = _damageSize;
     this.typeAttack = _typeAttack;
 }
Exemplo n.º 11
0
 public Damage()
 {
     this.damageSize = 0f;
     this.typeAttack = TypeAttack.NormalType;
 }
Exemplo n.º 12
0
    // Update is called once per frame
    void Update()
    {
        if (!isLocalPlayer || this.syncCharacter.Life < 0)
            return;
        // Visibilite et blocage du cursor

        if (tutoriel.End && tutoriel.CD <= 0)
        {
            if (Input.GetKeyDown(KeyCode.Return))
                this.social.ChatShown = !this.social.ChatShown;
            Cursor.visible = true;
            Cursor.lockState = CursorLockMode.None;
            return;
        }

        Cursor.visible = this.controller.Pause;
        Cursor.lockState = this.controller.Pause ? CursorLockMode.None : CursorLockMode.Locked;

        if (!this.character.activeInHierarchy)
            return;
        #region Near Element
        // Recherche du plus proche
        float dist = float.PositiveInfinity;
        GameObject lastNearElement = this.nearElement;
        this.nearElement = null;

        Collider[] cols = Physics.OverlapSphere(this.cam.transform.position, 0.45f);
        GameObject forbidden = null;
        if (cols.Length > 0)
            forbidden = cols[0].gameObject;

        foreach (Collider col in Physics.OverlapSphere(this.character.transform.position, 3.5f))
            if (col.transform.parent != null && col.transform.parent.CompareTag("Elements") && col.gameObject != forbidden
                         && Vector3.Distance(this.character.transform.position, col.transform.parent.transform.position) < dist)
            {
                this.nearElement = col.transform.parent.gameObject;
                dist = Vector3.Distance(this.character.transform.position, col.transform.parent.transform.position);
            }

        if (this.nearElement != lastNearElement)
        {
            gameObject.GetComponent<Sound>().PlaySound(AudioClips.Void, 0, 0.2f, 616);
            // Supprimer l'ancien outline
            if (lastNearElement != null)
            {
                foreach (MeshRenderer mr in lastNearElement.GetComponentsInChildren<MeshRenderer>())
                    foreach (Material mat in mr.materials)
                        mat.shader = Shader.Find("Standard");
                this.inventaire.Chest = null;
            }

            // Mettre le nouveau outline
            if (this.nearElement != null)
            {
                foreach (MeshRenderer mr in this.nearElement.GetComponentsInChildren<MeshRenderer>())
                    foreach (Material mat in mr.materials)
                        mat.shader = Shader.Find("Outlined");
                if (this.nearElement.name.Contains("Chest"))
                    this.inventaire.Chest = nearElement;
            }
        }
        #endregion

        #region Previsu
        if (this.inventaire.UsedItem.Items is WorkTop)
        {
            WorkTop wt = this.inventaire.UsedItem.Items as WorkTop;
            wt.Previsu.transform.position = (this.character.transform.position - this.character.transform.forward);
            wt.Previsu.transform.LookAt(new Vector3(this.character.transform.position.x, wt.Previsu.transform.position.y, this.character.transform.position.z));

            CmdupdateValid(wt.Previsu.transform.position);

            if (validplace != this.lastvalidplace)
            {
                string shadname = "Previsus/Previsu" + (validplace ? "" : "NOT") + "OK";
                foreach (MeshRenderer mesh in wt.Previsu.GetComponentsInChildren<MeshRenderer>())
                    foreach (Material mat in mesh.materials)
                        mat.shader = Shader.Find(shadname);
                this.lastvalidplace = validplace;
            }

        }
        #endregion

        #region Show/Hide GUI
        // show and hide the GUI
        if (Input.GetKeyDown (KeyCode.B) && gameObject.GetComponent<SpecMode>().isSpec && !gameObject.GetComponent<Social_HUD> ().ChatShown) {
            seeGUI = !seeGUI;
        }
        if ((Input.GetKeyDown(KeyCode.Return) || Input.GetButtonDown("Cancel")) && !seeGUI){
            seeGUI = true;
        }
        #endregion

        #region Gestion Menu
        if (Input.GetButtonDown("Inventory") && !this.menu.MenuShown && !this.menu.OptionShown && !this.social.ChatShown && !this.cristalHUD.Cristal_shown && !this.sucHUD.Activate && !this.tutoriel.EndTutoShown && !this.tutoriel.Tutoshown && !this.menu.ControlShown)
        {
            this.inventaire.InventoryShown = !this.inventaire.InventoryShown;
            this.controller.Pause = this.inventaire.InventoryShown;
            this.soundAudio.PlaySound(AudioClips.Bag, 1f);
        }

        if (Input.GetKeyDown(KeyCode.Return) && !this.menu.MenuShown && !this.menu.OptionShown && !this.inventaire.InventoryShown && !this.cristalHUD.Cristal_shown && !this.sucHUD.Activate && !this.tutoriel.EndTutoShown && !this.tutoriel.Tutoshown && !this.menu.ControlShown)
        {
            this.social.ChatShown = true;
            this.controller.Pause = true;
        }
        if (cdAttack <= 0 && (Input.GetKey(KeyCode.C)))
        {
            cdAttack = 1.5f;
            this.character.GetComponent<Rigidbody>().AddRelativeForce(new Vector3(0, 5000, 20000));
            this.controller.CdDisable = .5f;
        }
        #endregion

        #region Fire2
        bool useConsumable = false;
        if (Input.GetButton("Fire2") && !this.inventaire.InventoryShown && !this.menu.MenuShown && !this.menu.OptionShown && !this.social.ChatShown && !this.cristalHUD.Cristal_shown && !this.sucHUD.Activate && !this.tutoriel.EndTutoShown && !this.tutoriel.Tutoshown && !this.menu.ControlShown)
        {
            if (this.inventaire.UsedItem.Items is WorkTop)
            {
                WorkTop wt = this.inventaire.UsedItem.Items as WorkTop;
                if (validplace && this.soundAudio.IsReady(615))
                {
                    CmdSpawnElm(wt.ElementID, wt.Previsu.transform.position, wt.Previsu.transform.rotation);
                    this.CmdPut(wt.ID);
                    this.inventaire.UsedItem.Quantity -= 1;
                    if (this.inventaire.UsedItem.Quantity <= 0)
                        this.inventaire.UsedItem = new ItemStack();
                    this.soundAudio.PlaySound(AudioClips.Void, 0, 1, 615);
                }
            }
            else if (this.inventaire.UsedItem.Items is Consumable)
            {
                this.anim.SetInteger("Action", 7);
                this.cdConsume -= Time.deltaTime;
                useConsumable = true;
                if (this.cdConsume < 0)
                {
                    this.cdConsume = 1f;
                    this.anim.SetInteger("Action", 0);
                    Consumable consum = this.inventaire.UsedItem.Items as Consumable;
                    gameObject.GetComponent<SyncCharacter>().Affect(consum.E);
                    this.CmdConsumme(consum.ID);
                    this.inventaire.UsedItem.Quantity--;
                    if (this.inventaire.UsedItem.Quantity == 0)
                        this.inventaire.UsedItem = new ItemStack();
                }
            }
            else if (this.inventaire.UsedItem.Items is Sword || this.inventaire.UsedItem.Items is BattleAxe || this.inventaire.UsedItem.Items is Spear)
            {
                if (cdAttack <= 0 && !this.controller.Pause)
                {
                    this.anim.SetInteger("Action", 11);
                    this.attack = TypeAttack.Horizontal;
                    this.cdAttack = 5f;
                }
            }
            else if (this.nearElement != null && this.nearElement.GetComponent<SyncCore>() != null)
            {
                this.cristalHUD.Cristal = this.nearElement.GetComponent<SyncCore>();
                if (this.cristalHUD.Cristal.Team == this.social.Team || this.cristalHUD.Cristal.Team == Team.Neutre)
                {
                    this.cristalHUD.Cristal_shown = true;
                    this.controller.Pause = true;
                }
            }
            else if (this.nearElement != null && this.nearElement.GetComponent<SyncElement>() != null)
            {
                this.CmdInteractElement(this.nearElement.gameObject, this.inventaire.UsedItem.Items.ID);
            }
        }
        if (!useConsumable)
            this.cdConsume = 1;
        #endregion

        #region Fire1
        // Gestion de l'attaque
        if (cdAttack > 0)
            cdAttack -= Time.deltaTime;
        if (Input.GetButtonDown("Fire1") && cdAttack <= 0 && !this.controller.Pause)
        {
            this.cdAttack = 5f;
            if (this.controller.IsJumping && !(this.inventaire.UsedItem.Items is Spear) && this.inventaire.UsedItem.Items is Tool)
                this.attack = TypeAttack.Aerial;
            else if (this.controller.IsSprinting && !(this.inventaire.UsedItem.Items is BattleAxe) && this.inventaire.UsedItem.Items is Tool)
                this.attack = TypeAttack.Charge;
            else
                this.attack = TypeAttack.Vertical;
        }
        if (this.cdAttack > 4.8f)
            switch (this.attack)
            {
                case TypeAttack.Charge:
                    this.anim.SetInteger("Action", 9);
                    break;
                case TypeAttack.Aerial:
                    this.anim.SetInteger("Action", 10);
                    break;
                case TypeAttack.Vertical:
                    this.anim.SetInteger("Action", 6);
                    break;
                default:
                    break;
            }
        if (this.cdAttack < 4.8f && this.cdAttack > 4.7f)
        {

            if (this.attack == TypeAttack.Charge || this.attack == TypeAttack.Aerial || this.inventaire.UsedItem.Items is BattleAxe)
                this.cdAttack = 1.5f;
            else
                this.cdAttack = .6f;
            if (this.inventaire.UsedItem.Items is Tool)
            {
                this.soundAudio.PlaySound(AudioClips.playerAttack, 1);
                this.soundAudio.CmdPlaySound(AudioClips.playerAttack, 1);
            }

            // Calcul le damage
            float damage = 0f;
            Item item = this.inventaire.UsedItem.Items;
            if (item is Tool)
                damage = 5f * ((item as Tool).Damage) / 100f;
            else
                damage = 5f;
            CmdAttack(damage, attack, item is Spear);
        }
        #endregion

        #region Cancel
        if (Input.GetButtonDown("Cancel"))
        {
            this.soundAudio.PlaySound(AudioClips.Button, 1f);

            if (this.cristalHUD.Cristal_shown)
            {
                this.cristalHUD.Cristal_shown = false;
                this.controller.Pause = false;
            }
            else if (this.inventaire.InventoryShown)
            {
                this.inventaire.InventoryShown = false;
                this.controller.Pause = false;
            }
            else if (this.social.ChatShown)
            {
                this.social.ChatShown = false;
                this.controller.Pause = false;
            }
            else if (this.menu.OptionShown)
            {
                this.menu.OptionShown = false;
                this.menu.MenuShown = true;
            }
            else if (this.menu.SonShown)
            {
                this.menu.SonShown = false;
                this.menu.OptionShown = true;
            }
            else if (this.menu.LangueShown)
            {
                this.menu.LangueShown = false;
                this.menu.OptionShown = true;
            }
            else if (this.sucHUD.Activate)
            {
                this.sucHUD.Activate = false;
                this.menu.MenuShown = true;
            }
            else if (this.menu.ControlShown)
            {
                this.menu.ControlShown = false;
                this.menu.OptionShown = true;
            }
            else if (this.tutoriel.EndTutoShown)
            {
                this.tutoriel.EndTutoShown = false;
                this.controller.Pause = false;
            }
            else if (this.tutoriel.Tutoshown)
            {
                this.tutoriel.Tutoshown = false;
                this.controller.Pause = false;
            }
            else if (this.menu.Helpshown)
            {
                if (this.menu.Page != -1)
                    this.menu.Page = -1;
                else
                {
                    this.menu.Helpshown = false;
                    this.menu.MenuShown = true;
                }
            }
            else
            {
                this.menu.MenuShown = !this.menu.MenuShown;
                this.controller.Pause = this.menu.MenuShown;
            }
        }
        #endregion

        #region ToolBar
        // Gere la barre d'outil.
        if (!Input.GetKey("left ctrl") && !this.controller.Pause && !this.inventaire.InventoryShown)
        {
            if (Input.GetAxis("Mouse ScrollWheel") > 0)
                this.inventaire.Cursors++;

            if (Input.GetAxis("Mouse ScrollWheel") < 0)
                this.inventaire.Cursors--;
        }

        if (Input.GetKeyDown(KeyCode.Alpha1))
            this.inventaire.Cursors = 0;

        if (Input.GetKeyDown(KeyCode.Alpha2))
            this.inventaire.Cursors = 1;

        if (Input.GetKeyDown(KeyCode.Alpha3))
            this.inventaire.Cursors = 2;

        if (Input.GetKeyDown(KeyCode.Alpha4))
            this.inventaire.Cursors = 3;

        if (Input.GetKeyDown(KeyCode.Alpha5))
            this.inventaire.Cursors = 4;

        if (Input.GetKeyDown(KeyCode.Alpha6))
            this.inventaire.Cursors = 5;

        if (Input.GetButtonDown("Drop"))
        {
            if (this.inventaire.UsedItem.Quantity != 0)
            {
                this.inventaire.Drop(new ItemStack(this.inventaire.UsedItem.Items, 1));
                this.inventaire.UsedItem.Quantity--;
                if (inventaire.UsedItem.Quantity == 0)
                    this.inventaire.UsedItem = new ItemStack();
            }
        }
        #endregion
    }
Exemplo n.º 13
0
    // Use this for initialization
    void Start()
    {
        this.nearElement = null;
        this.character = GetComponentInChildren<CharacterCollision>().gameObject;
        this.social = GetComponent<Social_HUD>();
        this.attack = TypeAttack.None;
        this.syncCharacter = gameObject.GetComponent<SyncCharacter>();
        if (!isLocalPlayer)
            return;
        this.cam = GetComponentInChildren<Camera>().gameObject;
        this.inventaire = GetComponent<Inventory>();
        this.menu = GetComponent<Menu>();
        this.controller = GetComponent<Controller>();

        this.sucHUD = GetComponent<Success_HUD>();
        this.cristalHUD = GetComponent<Cristal_HUD>();
        this.tutoriel = GetComponent<Tutoriel>();
        this.anim = gameObject.GetComponent<Animator>();
        this.validplace = true;
        this.lastvalidplace = true;

        this.soundAudio = gameObject.GetComponent<Sound>();
        Cursor.visible = false;

        seeGUI = true;
    }
Exemplo n.º 14
0
 public Roca(string nombre) : base(nombre)
 {
     this.Tipo  = tipo;
     Attacks[0] = new TypeAttack("Avalancha", 65);
     Attacks[1] = new TypeAttack("Lanzarrocas", 50);
 }