示例#1
0
    public override Vector3 UpdateBehaviour(PetAI agent)
    {
        atPosition = false;

        targetPosition = playerScriptObject.GetComponent <PlayerScript>().petToPosition;

        float distanceFromTarget = Vector3.Distance(this.transform.position, targetPosition);

        if (targetPosition != this.transform.position && atPosition == false)
        {
            if (distanceFromTarget > arrivalRadius && distanceFromTarget > arrivalRadius * 10)
            {
                desiredVelocity = Vector3.Normalize(targetPosition - transform.position) * agent.Superspeed;
            }
            else if (distanceFromTarget > arrivalRadius && distanceFromTarget < arrivalRadius * 10)
            {
                desiredVelocity = Vector3.Normalize(targetPosition - transform.position) * agent.MaxSpeed;
            }
            else
            {
                desiredVelocity = Vector3.Normalize(targetPosition - transform.position) * distanceFromTarget;
            }
            steeringVelocity = desiredVelocity - agent.CurrentVelocity;
        }
        else
        {
            atPosition = true;
        }

        steeringVelocity.y = 0.0f;
        return(steeringVelocity);
    }
示例#2
0
        public void UpdateCharmAI()
        {
            if (IsCharmed())
            {
                UnitAI newAI = null;
                if (IsPlayer())
                {
                    Unit charmer = GetCharmer();
                    if (charmer != null)
                    {
                        // first, we check if the creature's own AI specifies an override playerai for its owned players
                        Creature creatureCharmer = charmer.ToCreature();
                        if (creatureCharmer != null)
                        {
                            CreatureAI charmerAI = creatureCharmer.GetAI();
                            if (charmerAI != null)
                            {
                                newAI = charmerAI.GetAIForCharmedPlayer(ToPlayer());
                            }
                        }
                        else
                        {
                            Log.outError(LogFilter.Misc, $"Attempt to assign charm AI to player {GetGUID()} who is charmed by non-creature {GetCharmerGUID()}.");
                        }
                    }
                    if (newAI == null) // otherwise, we default to the generic one
                    {
                        newAI = new SimpleCharmedPlayerAI(ToPlayer());
                    }
                }
                else
                {
                    Cypher.Assert(IsCreature());
                    if (IsPossessed() || IsVehicle())
                    {
                        newAI = new PossessedAI(ToCreature());
                    }
                    else
                    {
                        newAI = new PetAI(ToCreature());
                    }
                }

                Cypher.Assert(newAI != null);
                SetAI(newAI);
                newAI.OnCharmed(true);
            }
            else
            {
                RestoreDisabledAI();
                // Hack: this is required because we want to call OnCharmed(true) on the restored AI
                RefreshAI();
                UnitAI ai = GetAI();
                if (ai != null)
                {
                    ai.OnCharmed(true);
                }
            }
        }
示例#3
0
 // Start is called before the first frame update
 void Start()
 {
     anim       = GetComponent <Animator>();
     sr         = FindObjectOfType <PetAI>().GetComponent <SpriteRenderer>();
     Main       = GetComponent <SpriteRenderer>();
     ea         = FindObjectOfType <EatColor>();
     pa         = FindObjectOfType <PetAI>();
     sr.enabled = false;
     StartCoroutine("des");
 }
示例#4
0
 public static void SetTarget(PetAI ai, ushort instanceID, ref CitizenInstance data, ushort targetBuilding)
 {
     //begin mod
     if (IsCagedAnimal(data) || LivestockAIDetour.isFreeAnimal(data))
     {
         SetTargetCaged(instanceID, ref data, targetBuilding);
         return;
     }
     //end mod
     data.m_targetBuilding = targetBuilding;
 }
示例#5
0
    public override Vector3 UpdateBehaviour(PetAI steeringAgent)
    {
        // Get the desired velocity for arrival and limit to maxSpeed
        desiredVelocity = (targetPosition - transform.position);
        float distance = Vector3.Distance(targetPosition, transform.position);

        desiredVelocity.Normalize();

        if (distance < arrivalRadius)
        {
            desiredVelocity *= steeringAgent.MaxSpeed * (distance / arrivalRadius);
        }
        else
        {
            desiredVelocity *= 65;
        }

        // Calculate steering velocity
        steeringVelocity = desiredVelocity - steeringAgent.CurrentVelocity;
        return(steeringVelocity);
    }
示例#6
0
    public void CloseInteract()
    {
        //PetData petData = SaveSystem.A_LoadPet(petAI.id);
        target.transform.localScale = new Vector3(0.3f, 0.3f, 1);
        target.transform.position   = new Vector3(0, -1.5f, 0);
        target.transform.rotation   = Quaternion.identity;
        petAI.rigidbody.constraints = RigidbodyConstraints2D.None;
        petAI.PetAct      = PetActivity.Stand;
        petData.hunger    = (int)petAI.Hunger;
        petData.happiness = (int)petAI.Happiness;

        Transform[] roots = target.GetComponentsInChildren <Transform>();
        foreach (Transform g in roots)
        {
            g.gameObject.layer = 10;
        }

        interactCam.gameObject.SetActive(false);
        SaveSystem.A_EditPet(petData, true);
        if (foodDic.Count > 0)
        {
            SaveSystem.A_SaveListFood(foodDic);
        }
        petAI.Happiness = petAI.Happiness;
        petAI.Hunger    = petAI.Hunger;
        target.layer    = 10;
        timeer          = 0;
        petAI.aleart    = true;
        target          = null;
        petAI           = null;
        interactUI.SetActive(false);
        interactUIBG.SetActive(false);
        foodCanvasList.SetActive(false);
        dressUpBtn.onClick.Invoke();
        gameMode = GameMode.Normal;
    }
示例#7
0
        public void UpdateCharmAI()
        {
            switch (GetTypeId())
            {
            case TypeId.Unit:
                if (i_disabledAI != null)     // disabled AI must be primary AI
                {
                    if (!IsCharmed())
                    {
                        i_AI         = i_disabledAI;
                        i_disabledAI = null;

                        if (IsTypeId(TypeId.Unit))
                        {
                            ToCreature().GetAI().OnCharmed(false);
                        }
                    }
                }
                else
                {
                    if (IsCharmed())
                    {
                        i_disabledAI = i_AI;
                        if (isPossessed() || IsVehicle())
                        {
                            i_AI = new PossessedAI(ToCreature());
                        }
                        else
                        {
                            i_AI = new PetAI(ToCreature());
                        }
                    }
                }
                break;

            case TypeId.Player:
            {
                if (IsCharmed())         // if we are currently being charmed, then we should apply charm AI
                {
                    i_disabledAI = i_AI;

                    UnitAI newAI = null;
                    // first, we check if the creature's own AI specifies an override playerai for its owned players
                    Unit charmer = GetCharmer();
                    if (charmer)
                    {
                        Creature creatureCharmer = charmer.ToCreature();
                        if (creatureCharmer)
                        {
                            PlayerAI charmAI = creatureCharmer.IsAIEnabled ? creatureCharmer.GetAI().GetAIForCharmedPlayer(ToPlayer()) : null;
                            if (charmAI != null)
                            {
                                newAI = charmAI;
                            }
                        }
                        else
                        {
                            Log.outError(LogFilter.Misc, "Attempt to assign charm AI to player {0} who is charmed by non-creature {1}.", GetGUID().ToString(), GetCharmerGUID().ToString());
                        }
                    }
                    if (newAI == null)         // otherwise, we default to the generic one
                    {
                        newAI = new SimpleCharmedPlayerAI(ToPlayer());
                    }
                    i_AI = newAI;
                    newAI.OnCharmed(true);
                }
                else
                {
                    if (i_AI != null)
                    {
                        // we allow the charmed PlayerAI to clean up
                        i_AI.OnCharmed(false);
                    }
                    else
                    {
                        Log.outError(LogFilter.Misc, "Attempt to remove charm AI from player {0} who doesn't currently have charm AI.", GetGUID().ToString());
                    }
                    // and restore our previous PlayerAI (if we had one)
                    i_AI         = i_disabledAI;
                    i_disabledAI = null;
                    // IsAIEnabled gets handled in the caller
                }
                break;
            }

            default:
                Log.outError(LogFilter.Misc, "Attempt to update charm AI for unit {0}, which is neither player nor creature.", GetGUID().ToString());
                break;
            }
        }
示例#8
0
    private void LoadPet()
    {
        for (int i = 0; i < player.pets.Count; i++)
        {
            if (player.pets[i].color < 0 || !player.pets[i].selected || player.pets[i].status < 0)
            {
                continue;
            }

            PetAI clone = Instantiate(petPrefab.gameObject).GetComponent <PetAI>();
            clone.id        = player.pets[i].id;
            clone.namePet   = player.pets[i].namePet;
            clone.Hunger    = player.pets[i].hunger;
            clone.Happiness = player.pets[i].happiness;
            int color = player.pets[i].color;
            clone.head.sprite    = Atlas.Ins.GetSprites(Atlas.Ins.cha.head.color[color])[player.pets[i].head];
            clone.ear.sprite     = Atlas.Ins.GetSprites(Atlas.Ins.cha.ear.color[color])[player.pets[i].ear];
            clone.pattern.sprite = Atlas.Ins.GetSprites(Atlas.Ins.cha.pattern.color[color])[player.pets[i].pattern];
            clone.eye.sprite     = Atlas.Ins.GetSprites(Atlas.Ins.cha.eye)[player.pets[i].eye];
            clone.eyebrow.sprite = Atlas.Ins.GetSprites(Atlas.Ins.cha.eyebrow)[player.pets[i].eyebrow];
            clone.nose.sprite    = Atlas.Ins.GetSprites(Atlas.Ins.cha.nose)[player.pets[i].nose];
            clone.mouth.sprite   = Atlas.Ins.GetSprites(Atlas.Ins.cha.mouth)[player.pets[i].mouth];

            clone.body.sprite     = Atlas.Ins.GetSprites(Atlas.Ins.cha.body)[color];
            clone.armLeft.sprite  = Atlas.Ins.GetSprites(Atlas.Ins.cha.armLeft)[color];
            clone.armRight.sprite = Atlas.Ins.GetSprites(Atlas.Ins.cha.armRight)[color];
            clone.legLeft.sprite  = Atlas.Ins.GetSprites(Atlas.Ins.cha.legLeft)[color];
            clone.legRight.sprite = Atlas.Ins.GetSprites(Atlas.Ins.cha.legRight)[color];
            List <Sprite> sprite = new List <Sprite>();
            if (player.pets[i].shirtWearing >= 0)
            {
                sprite.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothes.shirt.number[player.pets[i].shirtWearing]));
            }
            if (sprite.Count > 1)
            {
                foreach (Sprite s in sprite)
                {
                    if (s.name.ToLower().Contains("body"))
                    {
                        clone.shirtBody.sprite = s;
                    }
                    else if (s.name.ToLower().Contains("left"))
                    {
                        clone.shirtLeft.sprite = s;
                    }
                    else if (s.name.ToLower().Contains("right"))
                    {
                        clone.shirtRight.sprite = s;
                    }
                }
            }
            else if (sprite.Count > 0)
            {
                clone.shirtBody.sprite = sprite[0];
            }
            sprite.Clear();
            if (player.pets[i].pantWearing >= 0)
            {
                sprite.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothes.pant.number[player.pets[i].pantWearing]));
            }
            if (sprite.Count > 1)
            {
                foreach (Sprite s in sprite)
                {
                    if (s.name.ToLower().Contains("body"))
                    {
                        clone.pantBody.sprite = s;
                    }
                    else if (s.name.ToLower().Contains("left"))
                    {
                        clone.pantLeft.sprite = s;
                    }
                    else if (s.name.ToLower().Contains("right"))
                    {
                        clone.pantRight.sprite = s;
                    }
                }
            }
            else if (sprite.Count > 0)
            {
                clone.pantBody.sprite = sprite[0];
            }

            sprite.Clear(); if (player.pets[i].shoeWearing >= 0)
            {
                sprite.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothes.shoe.number[player.pets[i].shoeWearing]));
            }
            foreach (Sprite s in sprite)
            {
                if (s.name.ToLower().Contains("left"))
                {
                    clone.shoeLeft.sprite = s;
                }
                else if (s.name.ToLower().Contains("right"))
                {
                    clone.shoeRight.sprite = s;
                }
            }

            sprite.Clear(); if (player.pets[i].accessoriesWearing >= 0)
            {
                sprite.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothes.ac));
            }
            if (sprite.Count > 0)
            {
                clone.ac.sprite = sprite[player.pets[i].accessoriesWearing];
            }

            petList.Add(clone);
        }

        foreach (Furniture f in player.inventory.furniture)
        {
            if (!f.furnitureIsUsing)
            {
                continue;
            }

            if (f.type == 3)
            {
                FurnitureData data = new FurnitureData();
                data.CloneData(f);
                ChangeFloor(data);
                continue;
            }
            if (f.type == 4)
            {
                FurnitureData data = new FurnitureData();
                data.CloneData(f);
                ChangeWallpaper(data);
                continue;
            }

            FurnitureData ff = new FurnitureData();
            ff.CloneData(f);
            CloneItem(ff);
        }
    }
示例#9
0
        void HandlePetActionHelper(Unit pet, ObjectGuid guid1, uint spellid, ActiveStates flag, ObjectGuid guid2, float x, float y, float z)
        {
            CharmInfo charmInfo = pet.GetCharmInfo();

            if (charmInfo == null)
            {
                Log.outError(LogFilter.Network, "WorldSession.HandlePetAction(petGuid: {0}, tagGuid: {1}, spellId: {2}, flag: {3}): object (GUID: {4} Entry: {5} TypeId: {6}) is considered pet-like but doesn't have a charminfo!",
                             guid1, guid2, spellid, flag, pet.GetGUID().ToString(), pet.GetEntry(), pet.GetTypeId());
                return;
            }

            switch (flag)
            {
            case ActiveStates.Command:                                       //0x07
                switch ((CommandStates)spellid)
                {
                case CommandStates.Stay:                                  //flat=1792  //STAY
                    pet.StopMoving();
                    pet.GetMotionMaster().Clear(false);
                    pet.GetMotionMaster().MoveIdle();
                    charmInfo.SetCommandState(CommandStates.Stay);

                    charmInfo.SetIsCommandAttack(false);
                    charmInfo.SetIsAtStay(true);
                    charmInfo.SetIsCommandFollow(false);
                    charmInfo.SetIsFollowing(false);
                    charmInfo.SetIsReturning(false);
                    charmInfo.SaveStayPosition();
                    break;

                case CommandStates.Follow:                                //spellid=1792  //FOLLOW
                    pet.AttackStop();
                    pet.InterruptNonMeleeSpells(false);
                    pet.ClearInPetCombat();
                    pet.GetMotionMaster().MoveFollow(GetPlayer(), SharedConst.PetFollowDist, pet.GetFollowAngle());
                    charmInfo.SetCommandState(CommandStates.Follow);

                    charmInfo.SetIsCommandAttack(false);
                    charmInfo.SetIsAtStay(false);
                    charmInfo.SetIsReturning(true);
                    charmInfo.SetIsCommandFollow(true);
                    charmInfo.SetIsFollowing(false);
                    break;

                case CommandStates.Attack:                                //spellid=1792  //ATTACK
                {
                    // Can't attack if owner is pacified
                    if (GetPlayer().HasAuraType(AuraType.ModPacify))
                    {
                        // @todo Send proper error message to client
                        return;
                    }

                    // only place where pet can be player
                    Unit TargetUnit = Global.ObjAccessor.GetUnit(GetPlayer(), guid2);
                    if (!TargetUnit)
                    {
                        return;
                    }

                    Unit owner = pet.GetOwner();
                    if (owner)
                    {
                        if (!owner.IsValidAttackTarget(TargetUnit))
                        {
                            return;
                        }
                    }

                    pet.ClearUnitState(UnitState.Follow);
                    // This is true if pet has no target or has target but targets differs.
                    if (pet.GetVictim() != TargetUnit || (pet.GetVictim() == TargetUnit && !pet.GetCharmInfo().IsCommandAttack()))
                    {
                        if (pet.GetVictim())
                        {
                            pet.AttackStop();
                        }

                        if (!pet.IsTypeId(TypeId.Player) && pet.ToCreature().IsAIEnabled)
                        {
                            charmInfo.SetIsCommandAttack(true);
                            charmInfo.SetIsAtStay(false);
                            charmInfo.SetIsFollowing(false);
                            charmInfo.SetIsCommandFollow(false);
                            charmInfo.SetIsReturning(false);

                            CreatureAI AI    = pet.ToCreature().GetAI();
                            PetAI      petAI = (PetAI)AI;
                            if (petAI != null)
                            {
                                petAI._AttackStart(TargetUnit);             // force target switch
                            }
                            else
                            {
                                AI.AttackStart(TargetUnit);
                            }

                            //10% chance to play special pet attack talk, else growl
                            if (pet.IsPet() && pet.ToPet().GetPetType() == PetType.Summon && pet != TargetUnit && RandomHelper.IRand(0, 100) < 10)
                            {
                                pet.SendPetTalk(PetTalk.Attack);
                            }
                            else
                            {
                                // 90% chance for pet and 100% chance for charmed creature
                                pet.SendPetAIReaction(guid1);
                            }
                        }
                        else                                            // charmed player
                        {
                            charmInfo.SetIsCommandAttack(true);
                            charmInfo.SetIsAtStay(false);
                            charmInfo.SetIsFollowing(false);
                            charmInfo.SetIsCommandFollow(false);
                            charmInfo.SetIsReturning(false);

                            pet.Attack(TargetUnit, true);
                            pet.SendPetAIReaction(guid1);
                        }
                    }
                    break;
                }

                case CommandStates.Abandon:                               // abandon (hunter pet) or dismiss (summoned pet)
                    if (pet.GetCharmerGUID() == GetPlayer().GetGUID())
                    {
                        GetPlayer().StopCastingCharm();
                    }
                    else if (pet.GetOwnerGUID() == GetPlayer().GetGUID())
                    {
                        Cypher.Assert(pet.IsTypeId(TypeId.Unit));
                        if (pet.IsPet())
                        {
                            if (pet.ToPet().GetPetType() == PetType.Hunter)
                            {
                                GetPlayer().RemovePet(pet.ToPet(), PetSaveMode.AsDeleted);
                            }
                            else
                            {
                                //dismissing a summoned pet is like killing them (this prevents returning a soulshard...)
                                pet.SetDeathState(DeathState.Corpse);
                            }
                        }
                        else if (pet.HasUnitTypeMask(UnitTypeMask.Minion))
                        {
                            ((Minion)pet).UnSummon();
                        }
                    }
                    break;

                case CommandStates.MoveTo:
                    pet.StopMoving();
                    pet.GetMotionMaster().Clear(false);
                    pet.GetMotionMaster().MovePoint(0, x, y, z);
                    charmInfo.SetCommandState(CommandStates.MoveTo);

                    charmInfo.SetIsCommandAttack(false);
                    charmInfo.SetIsAtStay(true);
                    charmInfo.SetIsFollowing(false);
                    charmInfo.SetIsReturning(false);
                    charmInfo.SaveStayPosition();
                    break;

                default:
                    Log.outError(LogFilter.Network, "WORLD: unknown PET flag Action {0} and spellid {1}.", flag, spellid);
                    break;
                }
                break;

            case ActiveStates.Reaction:                                      // 0x6
                switch ((ReactStates)spellid)
                {
                case ReactStates.Passive:                                 //passive
                    pet.AttackStop();
                    pet.ClearInPetCombat();
                    goto case ReactStates.Defensive;

                case ReactStates.Defensive:                               //recovery
                case ReactStates.Aggressive:                              //activete
                    if (pet.IsTypeId(TypeId.Unit))
                    {
                        pet.ToCreature().SetReactState((ReactStates)spellid);
                    }
                    break;
                }
                break;

            case ActiveStates.Disabled:                                      // 0x81    spell (disabled), ignore
            case ActiveStates.Passive:                                       // 0x01
            case ActiveStates.Enabled:                                       // 0xC1    spell
            {
                Unit unit_target = null;

                if (!guid2.IsEmpty())
                {
                    unit_target = Global.ObjAccessor.GetUnit(GetPlayer(), guid2);
                }

                // do not cast unknown spells
                SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellid, pet.GetMap().GetDifficultyID());
                if (spellInfo == null)
                {
                    Log.outError(LogFilter.Network, "WORLD: unknown PET spell id {0}", spellid);
                    return;
                }

                foreach (SpellEffectInfo effect in spellInfo.GetEffects())
                {
                    if (effect != null && (effect.TargetA.GetTarget() == Targets.UnitSrcAreaEnemy || effect.TargetA.GetTarget() == Targets.UnitDestAreaEnemy || effect.TargetA.GetTarget() == Targets.DestDynobjEnemy))
                    {
                        return;
                    }
                }

                // do not cast not learned spells
                if (!pet.HasSpell(spellid) || spellInfo.IsPassive())
                {
                    return;
                }

                //  Clear the flags as if owner clicked 'attack'. AI will reset them
                //  after AttackStart, even if spell failed
                if (pet.GetCharmInfo() != null)
                {
                    pet.GetCharmInfo().SetIsAtStay(false);
                    pet.GetCharmInfo().SetIsCommandAttack(true);
                    pet.GetCharmInfo().SetIsReturning(false);
                    pet.GetCharmInfo().SetIsFollowing(false);
                }

                Spell spell = new Spell(pet, spellInfo, TriggerCastFlags.None);

                SpellCastResult result = spell.CheckPetCast(unit_target);

                //auto turn to target unless possessed
                if (result == SpellCastResult.UnitNotInfront && !pet.IsPossessed() && !pet.IsVehicle())
                {
                    Unit unit_target2 = spell.m_targets.GetUnitTarget();
                    if (unit_target)
                    {
                        if (!pet.IsFocusing())
                        {
                            pet.SetInFront(unit_target);
                        }
                        Player player = unit_target.ToPlayer();
                        if (player)
                        {
                            pet.SendUpdateToPlayer(player);
                        }
                    }
                    else if (unit_target2)
                    {
                        if (!pet.IsFocusing())
                        {
                            pet.SetInFront(unit_target2);
                        }
                        Player player = unit_target2.ToPlayer();
                        if (player)
                        {
                            pet.SendUpdateToPlayer(player);
                        }
                    }
                    Unit powner = pet.GetCharmerOrOwner();
                    if (powner)
                    {
                        Player player = powner.ToPlayer();
                        if (player)
                        {
                            pet.SendUpdateToPlayer(player);
                        }
                    }

                    result = SpellCastResult.SpellCastOk;
                }

                if (result == SpellCastResult.SpellCastOk)
                {
                    unit_target = spell.m_targets.GetUnitTarget();

                    //10% chance to play special pet attack talk, else growl
                    //actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell
                    if (pet.IsPet() && (pet.ToPet().GetPetType() == PetType.Summon) && (pet != unit_target) && (RandomHelper.IRand(0, 100) < 10))
                    {
                        pet.SendPetTalk(PetTalk.SpecialSpell);
                    }
                    else
                    {
                        pet.SendPetAIReaction(guid1);
                    }

                    if (unit_target && !GetPlayer().IsFriendlyTo(unit_target) && !pet.IsPossessed() && !pet.IsVehicle())
                    {
                        // This is true if pet has no target or has target but targets differs.
                        if (pet.GetVictim() != unit_target)
                        {
                            pet.GetMotionMaster().Clear();
                            if (pet.ToCreature().IsAIEnabled)
                            {
                                CreatureAI AI    = pet.ToCreature().GetAI();
                                PetAI      petAI = (PetAI)AI;
                                if (petAI != null)
                                {
                                    petAI._AttackStart(unit_target);         // force victim switch
                                }
                                else
                                {
                                    AI.AttackStart(unit_target);
                                }
                            }
                        }
                    }

                    spell.Prepare(spell.m_targets);
                }
                else
                {
                    if (pet.IsPossessed() || pet.IsVehicle())         // @todo: confirm this check
                    {
                        Spell.SendCastResult(GetPlayer(), spellInfo, spell.m_SpellVisual, spell.m_castId, result);
                    }
                    else
                    {
                        spell.SendPetCastResult(result);
                    }

                    if (!pet.GetSpellHistory().HasCooldown(spellid))
                    {
                        pet.GetSpellHistory().ResetCooldown(spellid, true);
                    }

                    spell.Finish(false);
                    spell.Dispose();

                    // reset specific flags in case of spell fail. AI will reset other flags
                    if (pet.GetCharmInfo() != null)
                    {
                        pet.GetCharmInfo().SetIsCommandAttack(false);
                    }
                }
                break;
            }

            default:
                Log.outError(LogFilter.Network, "WORLD: unknown PET flag Action {0} and spellid {1}.", flag, spellid);
                break;
            }
        }
示例#10
0
 public abstract Vector3 UpdateBehaviour(PetAI agent);
示例#11
0
 // Use this for initialization
 void Awake()
 {
     instance = this;
 }
示例#12
0
    private void Normal()
    {
        if (gameMode != GameMode.Normal)
        {
            return;
        }
        if (Input.touchCount > 0)
        {
            Touch touch = Input.GetTouch(0);

            if (target != null)
            {
                timeer += Time.deltaTime;
            }

            switch (touch.phase)
            {
            case TouchPhase.Began:
                if (Popup.Ins.working || lottery.working || setting.working)
                {
                    return;
                }
                hit2D = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(touch.position), Vector2.zero);
                if (hit2D.collider != null && hit2D.collider.tag == "Pet")
                {
                    target = hit2D.collider.gameObject;
                    petAI  = target.GetComponent <PetAI>();
                }
                break;

            case TouchPhase.Moved:
                if (target != null && petAI != null)
                {
                    petAI.PetAct = PetActivity.Carry;
                    petAI.aleart = false;
                    ray          = Camera.main.ScreenPointToRay(touch.position);
                    target.transform.position = new Vector2(ray.origin.x, ray.origin.y);
                }
                break;

            case TouchPhase.Stationary:
                if (timeer > 0.2f && target != null && petAI != null)
                {
                    petAI.PetAct = PetActivity.Carry;
                    petAI.aleart = false;
                    ray          = Camera.main.ScreenPointToRay(touch.position);
                    target.transform.position = new Vector2(ray.origin.x, ray.origin.y);
                }
                break;

            case TouchPhase.Ended:
                if (timeer < 0.2f && petAI != null)
                {
                    petAI.rigidbody.constraints = RigidbodyConstraints2D.FreezeAll;
                    petAI.aleart = false;
                    target.transform.localScale = new Vector3(0.55f, 0.55f, 1);
                    target.transform.position   = new Vector3(0, -1.3f, -5);
                    target.transform.rotation   = new Quaternion(0, 0, 0, 0);
                    happiness.value             = petAI.Happiness / 100;
                    hunger.value = petAI.Hunger / 100;
                    Transform[] roots = target.GetComponentsInChildren <Transform>();
                    foreach (Transform g in roots)
                    {
                        g.gameObject.layer = 21;
                    }

                    interactCam.gameObject.SetActive(true);
                    target.layer = 21;
                    interactUI.SetActive(true);
                    interactUIBG.SetActive(true);
                    foodCanvasList.SetActive(true);
                    dressUpBtn.onClick.Invoke();
                    petAI.emoHappy.SetActive(false);
                    petAI.emooHungry.SetActive(false);
                    petAI.emoHappy.layer   = 10;
                    petAI.emooHungry.layer = 10;
                    gameMode     = GameMode.Interact;
                    petAI.PetAct = PetActivity.Stand;
                    tutor3.SetActive(true);
                    petData = SaveSystem.A_LoadPet(petAI.id);
                    foodDic.Clear();
                }
                else if (target != null && petAI != null)
                {
                    timeer       = 0;
                    petAI.aleart = true;
                    petAI.PetAct = PetActivity.Stand;

                    target.transform.rotation = new Quaternion(0, 0, 0, 0);
                    target = null;
                    petAI  = null;
                }
                break;

            case TouchPhase.Canceled:
                break;
            }
        }
    }