Ejemplo n.º 1
0
    void OnCollideFood(FoodBeh food)
    {
        var args = new FoodCollisionArgs {
            Ball    = this,
            FoodBeh = food
        };

        SendMessageUpwards(Constants.OnBallAndFoodCollision, args, SendMessageOptions.DontRequireReceiver);
    }
Ejemplo n.º 2
0
    void OnBallAndFoodCollision(FoodCollisionArgs args)
    {
        var ball = args.Ball;
        var food = args.FoodBeh;

        food.gameObject.SetActive(false);
        // 增加体重
        var player = ball.Player;
        var weight = player.CustomProperties.GetFloat("weight") + Constants.FOOD_WEIGHT;
        var props  = new PlayObject {
            { "weight", weight }
        };

        player.SetCustomProperties(props);
        // 通知事件
        var eventData = new PlayObject {
            { "pId", player.ActorId },
            { "fId", food.Data.Id }
        };
        var client = LeanCloudUtils.GetClient();

        client.SendEvent(Constants.EAT_EVENT, eventData);
    }