Ejemplo n.º 1
0
 private void DrawStaffProperties(ItemWeaponStaff item)
 {
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.LabelField("Mana", GUILayout.Width(60));
     item.mana = EditorGUILayout.IntField(item.mana, GUILayout.Width(60));
     EditorGUILayout.LabelField("Bullet", GUILayout.Width(60));
     item.bullet = (GameObject)EditorGUILayout.ObjectField(item.bullet, typeof(GameObject), false, GUILayout.Width(180));
     EditorGUILayout.LabelField("Model", GUILayout.Width(60));
     item.model = (GameObject)EditorGUILayout.ObjectField(item.model, typeof(GameObject), false);
     EditorGUILayout.EndHorizontal();
 }
Ejemplo n.º 2
0
    // by the animation event
    public void OnAttack()
    {
        if (weapon == null)
        {
            return;
        }
        PlayerController player = PlayerController.Instance;

        if (weapon.itemType == Item.ItemTypes.Staff)
        {
            ItemWeaponStaff staff = (ItemWeaponStaff)weapon;
            if (player.Mana >= staff.mana)
            {
                Instantiate(staff.bullet, player.mainCamera.transform.position, player.mainCamera.transform.rotation);
                player.Mana -= staff.mana;
            }
            else
            {
                UIController.Instance.ShowError("Not enought mana");
            }
        }
        else
        {
            RaycastHit hit;
            if (Physics.Raycast(player.mainCamera.transform.position, player.mainCamera.transform.TransformDirection(Vector3.forward), out hit, 4))
            {
                IHitable hitable = hit.collider.gameObject.GetComponent(typeof(IHitable)) as IHitable;
                if (hitable != null)
                {
                    DamageConfig damageWithStreanght = ((ItemWeaponMelee)weapon).damage.Copy();
                    damageWithStreanght.minPhysical += (int)(damageWithStreanght.minPhysical * 0.05f * PlayerController.Instance.experience.ActualStrenght);
                    damageWithStreanght.maxPhysical += (int)(damageWithStreanght.maxPhysical * 0.05f * PlayerController.Instance.experience.ActualStrenght);
                    hitable.Hit(new HitInfo(damageWithStreanght, hit.point, true, HitInfo.HitSources.Player));
                }
            }
        }
    }